11.5. CURRENT_TIMESTAMP
Available inDSQL, PSQL, ESQL
TypeTIMESTAMP
Syntax
|
CURRENT_TIMESTAMP [ (<precision>) ]
|
|<precision> ::= 0 | 1 | 2 | 3
The optional precision argument is not supported in ESQL.
CURRENT_TIMESTAMP
ParameterParameter | Description |
---|---|
precision | Precision. The default value is 3. Not supported in ESQL |
CURRENT_TIMESTAMP
returns the current server date and time.
The default is 3 decimals, i.e. milliseconds precision.
The default precision of
CURRENT_TIME
is 0 decimals, soCURRENT_TIMESTAMP
is not the exact sum ofCURRENT_DATE
andCURRENT_TIME
, unless you explicitly specify a precision (i.e.CURRENT_TIME(3)
orCURRENT_TIMESTAMP(0)
).Within a PSQL module (procedure, trigger or executable block), the value of
CURRENT_TIMESTAMP
will remain constant every time it is read. If multiple modules call or trigger each other, the value will remain constant throughout the duration of the outermost module. If you need a progressing value in PSQL (e.g. to measure time intervals), use Section 11.14, “'NOW'
”.
CURRENT_TIMESTAMP
and Firebird 4 time zone supportFirebird 4 will support time zones.
As part of this support, there will be an incompatibility with the CURRENT_TIMESTAMP
expression.
In Firebird 4, CURRENT_TIMESTAMP
will return the new TIMESTAMP WITH TIME ZONE
type.
In order for your queries to be compatible with database code of future Firebird versions, Firebird 3.0.4 introduced the LOCALTIMESTAMP
expression.
In Firebird 3.0, LOCALTIMESTAMP
is a synonym for CURRENT_TIMESTAMP
.
In Firebird 4, LOCALTIMESTAMP
will continue to work as it does now (returning TIMESTAMP [WITHOUT TIME ZONE]
), while CURRENT_TIMESTAMP
will return a different data type, TIMESTAMP WITH TIME ZONE
.
Unless you need to be able to downgrade your database to Firebird 3.0.3 or earlier, we recommend to start using LOCALTIMESTAMP
instead of CURRENT_TIMESTAMP
.
Examples
|
select current_timestamp from rdb$database
|-- returns e.g. 2008-08-13 14:20:19.6170
|
|select current_timestamp(2) from rdb$database
|-- returns e.g. 2008-08-13 14:20:23.1200
See alsoSection 11.4, “CURRENT_TIME
”, Section 11.11, “LOCALTIME
”, Section 11.12, “LOCALTIMESTAMP
”