Skip to main content
Previous sectionNext section

Date/Time Values

Work with date/time values.

Available Tools

The tools are grouped into the following categories: data type classes and tools to work with date/time values.

Available Data Type Classes

Class Name Logical Value ODBC Type XSD Type
%Date A date value in $HOROLOG format (see Current Date and Time). For example: 46674 DATE date
%Time A time value, expressed as the number of seconds past midnight. For example: 67080 TIME time
%TimeStamp A date value and a time value, in ODBC format (in YYYY-MM-DD HH:MM:SS.nnnnnnnnn). For example: 1968-10-15 18:38:47 TIMESTAMP dateTime
%UTC A UTC date and time value, in ODBC format. TIMESTAMP  
%MV.Date A MultiValue date. For example: 289 DATE date

Availability: All namespaces.

Available Tools for Working With Date/Time Values

Includes the TimeZone() class method.

Availability: All namespaces.

Includes class methods that you can use to work with date/time values. These include:

  • A large set of methods that implement SQL functions to extract date parts (DAYOFWEEK(), MONTHNAME(), YEAR(), and so on). You can use these methods in the same way that you use other class methods; you are not restricted to an SQL context.

  • Methods that implement SQL date conversion functions (CONVERT(), TODATE(), and TOTIMESTAMP())

  • Methods that add and subtract dates (DATEADD() and DATEDIFF())

  • SetDefaultTimePrecision()

  • SetToDateDefaultFormat()

Availability: All namespaces.

Includes the following class methods that you can use to convert or obtain information about date/time values:

  • IsDST()

  • LocalWithZTIMEZONEtoUTC()

  • UTCtoLocalWithZTIMEZONE()

Availability: All namespaces.

Provides a set of class methods for working with %TimeStamp values. These are as follows:

  • Compare()

  • ConvertHorologToTimeStamp()

  • ConvertUTCtoLocal()

  • LogicalToOdbc()

  • And others

Availability: All namespaces.

Reminder

The special variable $SYSTEM is bound to the %SYSTEM package. This means that (for ObjectScript) instead of ##class(%SYSTEM.class).method(), you can use $SYSTEM.class.method().

See Also