pymssql and date format

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • eight02645999@yahoo.com

    pymssql and date format

    hi
    i am using pymmsql to query a date column in MSSQL database table.
    However the result shows for example
    (datetime.datet ime(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

  • Steve Holden

    #2
    Re: pymssql and date format

    eight02645999@y ahoo.com wrote:[color=blue]
    > hi
    > i am using pymmsql to query a date column in MSSQL database table.
    > However the result shows for example
    > (datetime.datet ime(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
    >[/color]
    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:
    [color=blue][color=green][color=darkred]
    >>> str(datetime.da tetime(2006, 2, 16, 17, 50, 19))[/color][/color][/color]
    '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/

    Comment

    Working...