|
|
Datetime Pseudo-Literals
The following sections document datetime pseudo-literals.
CURRENT_DATE
Returns a DATE value denoting the current date (i.e. today).Syntax
Syntax for the CURRENT_DATE function:Rules
- The result is the current date (i.e. today) as a DATE value.
- In any given SQL statement, all references to CURRENT_DATE are effectively evaluated simultaneously from a single reading of the server clock. Thus the conditional expression CURRENT_DATE = CURRENT_DATE is guaranteed to always evaluate to true.
- In any given SQL statement, the value of CURRENT_DATE will always be equal to the DATE portion of LOCALTIMESTAMP.
Example
SET D = CURRENT_DATE;LOCALTIME
Returns a TIME value denoting the current time (i.e. now).Syntax
Syntax for the LOCALTIME function:seconds-precision is an unsigned integer value denoting the seconds precision for the returned TIME value.
Rules
- The result is the current time (i.e. now) as a TIME value.
- The value of seconds-precision must be between 0 and 9.
- If seconds-precision is not specified, the default value of 0 is assumed.
- In any given SQL statement, all references to LOCALTIME are effectively evaluated simultaneously from a single reading of the server clock. Thus the conditional expression LOCALTIME = LOCALTIME is guaranteed to always evaluate to true.
- In any given SQL statement, the value of LOCALTIME will always be equal to the TIME portion of LOCALTIMESTAMP.
LOCALTIMESTAMP
Returns a TIMESTAMP denoting the current date and time.Syntax
Syntax for the LOCALTIMESTAMP function:
seconds-precision is an unsigned integer value denoting the seconds precision for the returned TIME value.
Rules
- The result is the current date and time as a TIMESTAMP value.
- The value of seconds-precision must be between 0 and 9.
- If seconds-precision is not specified, the default value of 6 is assumed.
- In any given SQL statement, all references to LOCALTIMESTAMP are effectively evaluated simultaneously from a single reading of the server clock. Thus the conditional expression LOCALTIMESTAMP = LOCALTIMESTAMP is guaranteed to always evaluate to true.
- In any given SQL statement, the value of LOCALTIMESTAMP will always be equal to the combined value of CURRENT_DATE and LOCALTIME.
Example
CREATE TABLE EVENTS(ID INTEGER PRIMARY KEY, TS TIMESTAMP DEFAULT LOCALTIMESTAMP); INSERT INTO EVENTS(ID) VALUES (1); -- default value for TS inserted -- (e.g. 2002-01-18 11:25:07.230000) UPDATE EVENTS SET TS = LOCALTIMESTAMP WHERE ID <= 10;
|
Upright Database Technology AB Voice: +46 18 780 92 00 Fax: +46 18 780 92 40 dbtechnology@upright.se |
|
|