Skip to main content


A date/time function that returns the current UTC date and time.




Argument Description
precision Optional — A positive integer that specifies the time precision as the number of digits of fractional seconds. The default is 0 (no fractional seconds); this default is configurable.


GETUTCDATE returns Universal Time Constant (UTC) date and time as a timestamp. Because UTC time is the same everywhere on the planet, does not depend on the local timezone and is not subject to local time variants (such as Daylight Saving Time), this function is useful for applying consistent timestamps when users in different time zones access the same database.

GETUTCDATE returns a timestamp in %TimeStamp data type format (yyyy-mm-dd hh:mm:ss.ffff).

To change the default datetime string format, use the SET OPTION command with the various date and time options.

Typical uses for GETUTCDATE are in the SELECT statement select list or in the WHERE clause of a query. In designing a report, GETUTCDATE can be used to print the current date and time each time the report is produced. GETUTCDATE is also useful for tracking activity, such as logging the time that a transaction occurred.

GETUTCDATE can be used in CREATE TABLE to specify a field’s default value.

Other SQL Functions

GETUTCDATE returns the current UTC date and time as a timestamp.

All other timestamp functions return the local date and time: GETDATE, CURRENT_TIMESTAMP, NOW, and SYSDATE return the current local date and time as a timestamp.

GETDATE and CURRENT_TIMESTAMP provide a precision argument.

NOW, argumentless CURRENT_TIMESTAMP, and SYSDATE do not provide a precision argument; they take the system-wide default time precision.

CURDATE and CURRENT_DATE return the current local date. CURTIME and CURRENT_TIME return the current local time. These functions use the DATE or TIME data type. None of these functions support precision.

A TIMESTAMP data type stores and displays its value in the same format. The TIME and DATE data types store their values as integers in $HOROLOG format and can be displayed in a variety of formats.

Note that all Caché SQL timestamp functions except GETUTCDATE are specific to the local time zone setting. To get a current timestamp that is universal (independent of time zone) you can also use the ObjectScript $ZTIMESTAMP special variable. Note that you can set the precision for GETUTCDATE; $ZTIMESTAMP always returns a precision of 3.

Fractional Seconds Precision

GETUTCDATE can return up to nine digits of precision. The number of digits of precision returned is set using the precision argument. The default for the precision argument can be configured using the following:

  • SET OPTION with the TIME_PRECISION option.

  • The $SYSTEM.SQL.SetDefaultTimePrecision()Opens in a new tab method call.

  • Go to the Management Portal, select Configuration, SQL and Object Settings, General SQL Settings (System, Configuration, General SQL Settings). View and edit the current setting of Default time precision for GETDATE(), CURRENT_TIME, and CURRENT_TIMESTAMP.

Specify an integer 0 through 9 (inclusive) for the default number of decimal digits of precision to return. The default is 0. The actual precision returned is platform dependent; precision digits in excess of the precision available on your system are returned as zeroes.

Fractional seconds are always truncated, not rounded, to the specified precision.


The following example returns the current date and time as a UTC timestamp and as a local timestamp, both in TIMESTAMP format:

       GETDATE() AS LocalDateTime

The following example returns the current UTC date and time with fractional seconds having two digits of precision:


The following Embedded SQL example compares local (time zone specific) and universal (time zone independent) timestamps:

    WRITE !,"Error code ",SQLCODE }
  ELSE {
    WRITE !,"Local timestamp is:  ",a
    WRITE !,"UTC timestamp is:    ",b

The following example sets the LastUpdate field in the selected row of the Orders table to the current UTC date and time. GETUTCDATE returns the current UTC date and time as an ODBC timestamp:

  WHERE Orders.OrderNumber=:ord

In the following example, the CREATE TABLE statement uses GETUTCDATE to set a default value for the OrderRcvd field:

     OrderId     INT NOT NULL,
     ItemName    CHAR(40) NOT NULL,
     Quantity    INT NOT NULL,

See Also

FeedbackOpens in a new tab