FirebirdSQL logo

LOCALTIMESTAMP

Current server time and date in the session time zone, without time zone information

Type

TIMESTAMP WITHOUT TIME ZONE

Syntax
LOCALTIMESTAMP [ (<precision>) ]

<precision> ::= 0 | 1 | 2 | 3

The optional precision argument is not supported in ESQL.

Table 1. LOCALTIMESTAMP Parameter
Parameter Description

precision

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

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

Note
  • LOCALTIMESTAMP was introduced in Firebird 3.0.4 and Firebird 2.5.9 as a synonym of CURRENT_TIMESTAMP.In Firebird 5.0, CURRENT_TIMESTAMP returns a TIMESTAMP WITH TIME ZONE instead of a TIMESTAMP [WITHOUT TIME ZONE], while LOCALTIMESTAMP returns TIMESTAMP [WITHOUT TIME ZONE].It is recommended to use LOCALTIMESTAMP when you do not need time zone information.

  • 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 [fblangref50-contextvars-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

NEW

Record with the inserted or updated values of a row

Available in

PSQL — triggers only,
DSQL — RETURNING clause of UPDATE, UPDATE OR INSERT and MERGE

Type

Record type

Syntax
NEW.column_name
Table 1. NEW Parameters
Parameter Description

column_name

Column name to access

NEW contains the new version of a database record that has just been inserted or updated.NEW is read-only in AFTER triggers.

Note

In multi-action triggers NEW is always available.However, if the trigger is fired by a DELETE, there will be no new version of the record.In that situation, reading from NEW will always return NULL;writing to it will cause a runtime exception.

'NOW'

Current date and/or time in cast context

Type

CHAR(3), or depends on explicit CAST

'NOW' is not a variable, but a string literal or datetime mnemonic.It is, however, special in the sense that when you CAST() it to a datetime type, you will get the current date and/or time.If the datetime type has a time component, the precision is 3 decimals, i.e. milliseconds.'NOW' is case-insensitive, and the engine ignores leading or trailing spaces when casting.

Note
Examples
select 'Now' from rdb$database
-- returns 'Now'

select cast('Now' as date) from rdb$database
-- returns e.g. 2008-08-13

select cast('now' as time) from rdb$database
-- returns e.g. 14:20:19.6170

select cast('NOW' as timestamp) from rdb$database
-- returns e.g. 2008-08-13 14:20:19.6170

OLD

Record with the initial values of a row before update or delete

Available in

PSQL — triggers only,
DSQL — RETURNING clause of UPDATE, UPDATE OR INSERT and MERGE

Type

Record type

Syntax
OLD.column_name
Table 1. OLD Parameters
Parameter Description

column_name

Column name to access

OLD contains the existing version of a database record just before a deletion or update.The OLD record is read-only.

Note

In multi-action triggers OLD is always available.However, if the trigger is fired by an INSERT, there is obviously no pre-existing version of the record.In that situation, reading from OLD will always return NULL.