11.12LOCALTIMESTAMP

Available inDSQL, PSQL, ESQL

TypeTIMESTAMP

Syntax

  |LOCALTIMESTAMP [ (<precision>) ]
  | 
  |<precision> ::= 0 | 1 | 2 | 3

The optional precision argument is not supported in ESQL.

Table 11.4LOCALTIMESTAMP Parameter
ParameterDescription

precision

Precision. The default value is 3. Not supported in ESQL

LOCALTIMESTAMP returns the current server date and time. The default is 3 decimals, i.e. milliseconds precision.

Note
  • LOCALTIMESTAMP was introduced in Firebird 3.0.4 as a synonym of CURRENT_TIMESTAMP. In Firebird 4, CURRENT_TIMESTAMP will return a TIMESTAMP WITH TIME ZONE instead of a TIMESTAMP [WITHOUT TIME ZONE], while LOCALTIMESTAMP will continue to return TIMESTAMP [WITHOUT TIME ZONE]. It is recommended to switch from CURRENT_TIMESTAMP to LOCALTIMESTAMP for forward-compatibility with Firebird 4.

  • The default precision of LOCALTIME is 0 decimals, so LOCALTIMESTAMP is not the exact sum of CURRENT_DATE and LOCALTIME, unless you explicitly specify a precision (i.e. LOCATIME(3) or LOCALTIMESTAMP(0)).

  • Within a PSQL module (procedure, trigger or executable block), the value of LOCALTIMESTAMP 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'.

Examples

  |select localtimestamp from rdb$database
  |-- returns e.g. 2008-08-13 14:20:19.6170
  | 
  |select localtimestamp(2) from rdb$database
  |-- returns e.g. 2008-08-13 14:20:23.1200

See alsoSection 11.5, “CURRENT_TIMESTAMP, Section 11.11, “LOCALTIME