Converts date and time values, or a character
string, into a DATETIME value.
Note: If any argument is the Unknown value (?), the result is the
Unknown value (?).
Syntax
DATETIME ( date-exp[ , mtime-exp ] )
|
DATETIME ( month , day , year , hours , minutes
[ , seconds[ , milliseconds]] )
|
-
date-exp
- An expression whose value is a DATE.
-
mtime-exp
- An expression whose value is an integer representing the number
of milliseconds since midnight.
-
string
- A character expression whose value is a string containing a
DATETIME. The date portion of the string must have the format specified
by the DATE-FORMAT attribute.
The time portion must be in a valid time format (HH:MM:SS, and so
on).
-
month
- An expression whose value is an integer from 1 to 12, inclusive.
-
day
- An expression whose value is an integer from 1 to the highest
valid day of the month.
-
year
- An expression that evaluates to a year.
-
hours
- An expression whose value is an integer from 0 to 23, inclusive.
-
minutes
- An expression whose value is an integer from 0 to 59, inclusive.
-
seconds
- An expression whose value is an integer from 0 to 61, inclusive.
The upper limit is 61 for leap seconds.
-
milliseconds
- An expression whose value is an integer from 0 to 999, inclusive.
Example
Following
is an example of using the DATETIME function:
DEFINE VARIABLE my-datetime AS DATETIME NO-UNDO.
/* This statement is equivalent to "my-datetime = NOW". */
my-datetime = DATETIME(TODAY, MTIME).
|
The following statements result in the same
DATETIME value:
my-datetime = DATETIME(5, 5, 2002, 7, 15, 3).
my-datetime = DATETIME("05-05-2002 07:15:03").
|
See also
ADD-INTERVAL function, DATE function, DATE-FORMAT attribute, DATETIME-TZ function, DAY function, ETIME function, INTERVAL function, ISO-DATE function, MONTH function, MTIME function, NOW function, TIME function, TIMEZONE function, TODAY function, WEEKDAY function, YEAR function, YEAR-OFFSET attribute