21.10.2013 Views

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

Firebird 2.1 Language Reference Update

SHOW MORE
SHOW LESS

You also want an ePaper? Increase the reach of your titles

YUMPU automatically turns print PDFs into web optimized ePapers that Google loves.

Available in: DSQL, PSQL, ESQL<br />

Changed in: 2.0<br />

Context variables<br />

'NOW'<br />

Description: 'NOW' is not a variable but a string literal. It is, however, special in the sense that when you CAST()<br />

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<br />

“.0000”, giving an effective seconds precision. Since <strong>Firebird</strong> 2.0 the precision is 3 decimals, i.e. milliseconds.<br />

'NOW' is case-insensitive, and the engine ignores leading or trailing spaces when casting.<br />

Type: CHAR(3)<br />

Examples:<br />

Notes:<br />

select 'Now' from rdb$database<br />

-- returns 'Now'<br />

select cast('Now' as date) from rdb$database<br />

-- returns e.g. 2008-08-13<br />

select cast('now' as time) from rdb$database<br />

-- returns e.g. 14:20:19.6170<br />

select cast('NOW' as timestamp) from rdb$database<br />

-- returns e.g. 2008-08-13 14:20:19.6170<br />

Shorthand syntax for the last three statements:<br />

select date 'Now' from rdb$database<br />

select time 'now' from rdb$database<br />

select timestamp 'NOW' from rdb$database<br />

• 'NOW' always returns the actual date/time, even in PSQL modules, where CURRENT_DATE, CURRENT_TIME<br />

and CURRENT_TIMESTAMP return the same value throughout the duration of the outermost routine. This<br />

makes 'NOW' useful for measuring time intervals in triggers, procedures and executable blocks.<br />

• Except in the situation mentioned above, reading CURRENT_DATE, CURRENT_TIME and<br />

CURRENT_TIMESTAMP is generally preferable to casting 'NOW'. Be aware though that CURRENT_TIME defaults<br />

to seconds precision; to get milliseconds precision, use CURRENT_TIME(3).<br />

Available in: PSQL, triggers only<br />

Changed in: 1.5, 2.0<br />

OLD<br />

114

Hooray! Your file is uploaded and ready to be published.

Saved successfully!

Ooh no, something went wrong!