Why the timestamp returned by the CURRENT TIMESTAMP special register in DB2 for Windows have a precision of only a millisecond?

Technote (FAQ)


Question

In DB2 UDB for Linux/Unix platforms, the "CURRENT TIMESTAMP" special register can return a timestamp with a precision of microseconds. For example,

db2 "values (CURRENT TIMESTAMP)"

1
--------------------------
2010-06-20-16.53.34.392348

However, in Windows the last 3 digits representing microseconds in the returned timestamp are always 000.

db2 "values (CURRENT TIMESTAMP)"

1
--------------------------
2010-06-20-15.42.04.578000

Therefore why in DB2 UDB for Windows platforms it can only have precision of milliseconds?

Cause

DB2 calls a Windows timing API to get the current timestamp. However, this Windows API can only return a precision to a millisecond. Thus DB2 returns whatever returned from the Windows API call.

Answer

This is a known limitation with the CURRENT TIMESTAMP special register in DB2 UDB for Windows. That is, in DB2 UDB for Windows platforms the CURRENT TIMESTAMP special register can only return a timestamp with precision of a millisecond.

To overcome the above limitation, you may consider using the DB2 function GENERATE_UNIQUE to get a timestamp with higher precision. For example,

db2 "values (TIMESTAMP(GENERATE_UNIQUE()) + CURRENT TIMEZONE)"

1
--------------------------
2010-06-20-15.59.36.030691


Related information

CURRENT TIMESTAMP special register

Rate this page:

(0 users)Average rating

Add comments

Document information


More support for:

DB2 for Linux, UNIX and Windows
Operating System Services (OSS) - OSSe

Software version:

9.1, 9.5, 9.7

Operating system(s):

Windows

Software edition:

Enterprise Server, Express, Personal, Personal Developer's, Workgroup Server

Reference #:

1438229

Modified date:

2012-11-07

Translate my page

Machine Translation

Content navigation