Results 1 to 3 of 3
  1. #1
    Join Date
    Sep 2003
    Location
    Toronto, Ontario
    Posts
    6

    Unanswered: Dates as Character Strings

    Due to a limitation of Python and ODBC, when I query a date/time field from an Access database, if the date is outside the range 1970 to 2038, I get a -1 returned. Is there a function I can use in my SQL that will return the date/time field as a character string?

    For example, in DB2 I write:

    select char(date-field) from tablename

  2. #2
    Join Date
    Aug 2003
    Location
    SW Ohio
    Posts
    198

    Re: Dates as Character Strings

    Originally posted by TheBru
    Due to a limitation of Python and ODBC, when I query a date/time field from an Access database, if the date is outside the range 1970 to 2038, I get a -1 returned. Is there a function I can use in my SQL that will return the date/time field as a character string?

    For example, in DB2 I write:

    select char(date-field) from tablename
    Try

    select cstr(date-field) from tablename
    select format(date-field, "MM/DD/YYYY") from tablename
    If you need time also
    select format(date-field, "MM/DD/YYYY hh:nn:ss am/pm") from tablename
    select datevalue(date-field) from tablename

    If none of these work, let me know.
    Jim P.

    Supoorting Oracle, MSSQL7, Sybase 8, & Pervasive. Confusion Reigns

  3. #3
    Join Date
    Sep 2003
    Location
    Toronto, Ontario
    Posts
    6
    Thanks for the extremely fast response!

    Those two functions, particularly the format function, do exactly what I need.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •