pymssql and date format

Steve Holden steve at holdenweb.com
Thu Feb 16 18:10:38 EST 2006


eight02645999 at yahoo.com wrote:
> hi
> i am using pymmsql to query a date column in MSSQL database table.
> However the result shows for example
> (datetime.datetime(2006, 2, 16, 17, 50, 19) which is supposed to be
> 2006-02-16 17:50:19.000
> anyway to correct query a date column using pymssql so that it gives
> the correct date format? thanks
> 
It doesn't return a format, it returns a value. I presume you are saying 
that you don't like the way the value prints? Use str() on it:

  >>> str(datetime.datetime(2006, 2, 16, 17, 50, 19))
'2006-02-16 17:50:19'

regards
  Steve
-- 
Steve Holden       +44 150 684 7255  +1 800 494 3119
Holden Web LLC                     www.holdenweb.com
PyCon TX 2006                  www.python.org/pycon/




More information about the Python-list mailing list