DATETIME qual1 TO qual2

The DATETIME data type stores date and time data with time units from the year to fractions of a second.

Syntax

DATETIME qual1 TO qual2
where qual1 can be one of:
  YEAR
  MONTH
  DAY
  HOUR
  MINUTE
  SECOND
  FRACTION
and qual2 can be one of:
  YEAR
  MONTH
  DAY
  HOUR
  MINUTE
  SECOND
  FRACTION
  FRACTION(1)
  FRACTION(2)
  FRACTION(3)
  FRACTION(4)
  FRACTION(5)
  1. qual1 and qual2 qualifiers define the precision of the DATETIME type.

Usage

The DATETIME data type stores an instance in time, expressed as a calendar date and time-of-day.

The qual1 and qual2 qualifiers define the precision of the DATETIME variable. The precision can range from a year through a fraction of second.

DATETIME arithmetic is based on the INTERVAL data type, and can be combined with DATE values:

Table 1. Datetime Arithmetic operators
Left Operand Type Operator Right Operand Type Result Type
DATETIME - DATETIME INTERVAL
DATETIME - DATE INTERVAL
DATETIME - INTERVAL DATETIME
DATETIME + INTERVAL DATETIME

The CURRENT operator provides current system date/time.

You can assign DATETIME variables with datetime literals with a specific notation.

DATETIME variables are initialized to NULL in functions, modules and globals.

DATETIME values can be converted to strings by the format YYYY-MM-DD hh:mm:ss.fffff.

MAIN
  DEFINE d1, d2 DATETIME YEAR TO MINUTE
  LET d1 = CURRENT YEAR TO MINUTE 
  LET d2 = "1998-01-23 12:34"
  DISPLAY d1, d2
END MAIN