<< NEW | FB 2.5 Language Reference | OLD >>


Available in: DSQL, PSQL, ESQL

Changed in: 2.0


'NOW' is not a variable but a string literal. It is, however, special in the sense that when you CAST() it to a date/time type, you will get the current date and/or time. The fractional part of the time used to be always .0000, giving an effective seconds precision. In Firebird 2.0 the precision is 3 decimals, i.e. milliseconds. 'NOW' is case-insensitive, and the engine ignores leading or trailing spaces when casting.

Type: CHAR(3)


 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

Shorthand syntax for the last three statements:

 select date 'Now' from rdb$database

 select time 'now' from rdb$database

 select timestamp 'NOW' from rdb$database


  • When used with CAST(), 'NOW' always returns the actual date/time, even in PSQL modules, where CURRENT_DATE, CURRENT_TIME and CURRENT_TIMESTAMP return the same value throughout the duration of the outermost routine. This makes 'NOW' useful for measuring time intervals in triggers, procedures and executable blocks.
  • When used with the shorthand syntax, 'NOW' is evaluated at parse time and the value is frozen for as long as the statement stays prepared even across multiple executions of the prepared statement! This is something to be aware of.
  • Unless you really need progressing values in PSQL, or frozen values during multiple executions, reading CURRENT_DATE, CURRENT_TIME and CURRENT_TIMESTAMP is generally preferable to using 'NOW'. Be aware though that CURRENT_TIME defaults to seconds precision; to get milliseconds precision, use CURRENT_TIME(3).

See also:
The difference between CURRENT_TIMESTAMP and 'NOW'

back to top of page
<< NEW | FB 2.5 Language Reference | OLD >>