Firebird Documentation IndexFirebird 2.5 Language Ref. UpdateMiscellaneous language elements → Shorthand datetime casts
Firebird Home Firebird Home Prev: Hexadecimal notation for “binary” stringsFirebird Documentation IndexUp: Miscellaneous language elementsNext: CASE construct

Shorthand datetime casts

Available in: DSQL, ESQL, PSQL

Added in: IB

Description: When converting a string literal to a DATE, TIME or TIMESTAMP, Firebird allows the use of a shorthand “C-style” cast. This feature already existed in InterBase 6, but was never properly documented.

Syntax: 

datatype 'date/timestring'

Examples: 

update People set AgeCat = 'Old'
  where BirthDate < date '1-Jan-1943'
insert into Appointments
  (Employee_Id, Client_Id, App_date, App_time)
values
  (973, 8804, date 'today' + 2, time '16:00')
new.lastmod = timestamp 'now';

Note: Please be advised that these shorthand expressions are evaluated immediately at parse time and stay the same as long as the statement remains prepared. Thus, even if a query is executed multiple times, the value for e.g. “timestamp 'now'” won't change, no matter how much time passes. If you need the value to progress (i.e. be evaluated upon every call), use a full cast.

See also: CAST

Prev: Hexadecimal notation for “binary” stringsFirebird Documentation IndexUp: Miscellaneous language elementsNext: CASE construct
Firebird Documentation IndexFirebird 2.5 Language Ref. UpdateMiscellaneous language elements → Shorthand datetime casts