Results 1 to 5 of 5
  1. #1
    Join Date
    Aug 2004
    Posts
    138

    date to timestamp conversion

    UDB V8.1 fp6a
    AIX 5.2

    Can any one tell me how to convert a date in the format of MM/DD/YYYY to timestamp format of YYYY-MM-DD HH24:MIS ?

    I tried timestamp_format function..unable to get the results I wanted

  2. #2
    Join Date
    May 2003
    Location
    USA
    Posts
    5,734
    Since you are starting with date and converting to timestamp, I assume the hours, minutes, seconds, etc can be zero.

    select char(birthdate, iso)||' 00:00:00.000000' from emp
    M. A. Feldman
    IBM Certified DBA on DB2 for Linux, UNIX, and Windows
    IBM Certified DBA on DB2 for z/OS and OS/390

  3. #3
    Join Date
    Aug 2004
    Posts
    138
    Thabks Marcus !! I 'll try it

  4. #4
    Join Date
    Aug 2003
    Location
    Massachusetts, USA
    Posts
    106
    Or use timestamp_iso. Example below

    values(timestamp_iso(current date))

  5. #5
    Join Date
    Sep 2004
    Location
    Belgium
    Posts
    1,126
    Or use the "TIMESTAMP" cast function with two arguments; this will also allow you to set the time in addition to the date:
    Code:
    timestamp(current date, '16:11:12')
    --_Peter Vanroose,
    __IBM Certified Database Administrator, DB2 9 for z/OS
    __IBM Certified Application Developer
    __ABIS Training and Consulting
    __http://www.abis.be/

Posting Permissions

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