Topic
  • 1 reply
  • Latest Post - ‏2012-12-20T10:16:32Z by SystemAdmin
SystemAdmin
SystemAdmin
4179 Posts

Pinned topic Problems at selecting a timestamp from DB2

‏2012-12-18T08:24:13Z |
Hi,

I hava a problem with the timestamp format.
In my DB2 database stands the following timestamp format: 2012-12-17 17:02:09.133104

Now I'd like to select this ts, but i get only this value : 2012-12-17 17:02:09.133
So, whats happened to the last three figures?

Thanks in advance
Updated on 2012-12-20T10:16:32Z at 2012-12-20T10:16:32Z by SystemAdmin
  • SystemAdmin
    SystemAdmin
    4179 Posts

    Re: Problems at selecting a timestamp from DB2

    ‏2012-12-20T10:16:32Z  
    I solved it!
    The answer is to cast the timestamp as CHARACTER (cast as TIMESTAMP doesn't work), like that:

    SET ts = CAST(exampleTimestamp AS CHARACTER FORMAT 'yyyy-MM-dd HH:mm:ss.SSSSSS');

    Cast as CHARACTER:
    ts = 2012-12-17 17:02:09.133104;

    Cast as TIMESTAMP:
    ts = 2012-12-17 17:02:09.133;

    Maybe, someone need this solution :)