InterSystems IRIS Data Platform 2019.2  /  InterSystems SQL Reference  /  SQL Functions

InterSystems SQL Reference
Previous section           Next section
InterSystems: The power behind what matters   

A date/time function that returns the current local time.
precision 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.
CURRENT_TIME returns the TIME data type.
CURRENT_TIME takes either no arguments or a precision argument. Empty argument parentheses are not permitted.
CURRENT_TIME returns the current local time for this timezone. It adjusts for local time variants, such as Daylight Saving Time.
CURRENT_TIME in Logical mode returns the current local time in $HOROLOG format; for example, 37065. CURRENT_TIME in Display mode returns the current local time in the default format for the locale; for example, 10:18:27.
To change the default time format, use the SET OPTION command with the TIME_FORMAT and TIME_PRECISION options. You can configure fractional seconds of precision, as described below.
To return just the current time, use CURRENT_TIME or CURTIME. These functions return their values in TIME data type. The CURRENT_TIMESTAMP, GETDATE and NOW functions can also be used to return the current date and time as a TIMESTAMP data type.
Note that all InterSystems SQL time and date 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 use GETUTCDATE or the ObjectScript $ZTIMESTAMP special variable.
These data types perform differently when using embedded SQL. The TIME data type stores values as integers in $HOROLOG format (as the number of seconds since midnight); when displayed in SQL they are converted to time display format; when returned from embedded SQL they are returned as integers. A TIMESTAMP data type stores and displays its value in the same format. You can use the CAST or CONVERT function to change the datatype of times and dates.
CURRENT_TIME can be used as a default specification keyword in CREATE TABLE or ALTER TABLE. CURRENT_TIME cannot specify a precision argument when used as a default specification keyword.
Fractional Seconds Precision
CURRENT_TIME can return up to nine digits of fractional seconds of precision. The default for the number of digits of precision can be configured using the following:
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; digits of precision in excess of the precision available on your system are returned as zeroes.
The following example returns the current system time:
The following example returns the current system time with three digits of fractional seconds precision:
The following Embedded SQL example returns the current time. Because this time is stored in $HOROLOG format, it is returned as an integer:
    WRITE !,"Error code ",SQLCODE }
  ELSE {
    WRITE !,"Current time is: ",a }
The following example sets the LastCall field in the selected row of the Contacts table to the current system time:
  WHERE Contacts.ItemNumber=:item
See Also

Previous section           Next section
Send us comments on this page
View this book as PDF   |  Download all PDFs
Copyright © 1997-2019 InterSystems Corporation, Cambridge, MA
Content Date/Time: 2019-09-19 06:56:35