Boolean Literals
A Boolean literal is one of TRUE
, FALSE
or UNKNOWN
.
A Boolean literal is one of TRUE
, FALSE
or UNKNOWN
.
Formally, the SQL standard defines datetime literals as a prefix DATE
, TIME
and TIMESTAMP
followed by a string literal with a datetime format.Historically, Firebird documentation has referred to these datetime literals as “shorthand casts”.
Since Firebird 4.0, the use of datetime mnemonics in datetime literals (e.g. DATE 'TODAY'
) is no longer allowed.
Caution
|
The format of datetime literals and strings in Firebird 4.0 and higher is more strict compared to earlier Firebird versions. |
<datetime_literal> ::= DATE '<date_format>' | TIME { '<time_format>' | '<time_tz_format>' } | TIMESTAMP { '<timestamp_format>' | '<timestamp_tz_format>' }
<date_format> ::= [YYYY<p>]MM<p>DD | MM<p>DD[<p>{ YYYY | YY }] | DD<p>MM[<p>{ YYYY | YY }] <time_format> ::= HH[:mm[:SS[<f>NNNN]]] <timestamp_format> ::= <date_format> [<space> <time_format>] <time_zone> ::= { + | - }HH:MM | time zone name (e.g. Europe/Berlin) <time_tz_format> ::= <time_format> [<space>] <time_zone> <timestamp_tz_format> ::= <timestamp_format> [<space>] <time_zone> <p> ::= whitespace | . | - | / <f> ::= : | .
Argument | Description |
---|---|
datetime_literal |
Datetime literal |
date_format |
Format of date |
time_format |
Format of time |
timestamp_format |
Format of timestamp |
time_zone |
Format of time zone |
time_tz_format |
Format of time with time zone |
timestamp_tz_format |
Format of timestamp with time zone |
YYYY |
Four-digit year |
YY |
Two-digit year |
MM |
MonthIt may contain 1 or 2 digits (1-12 or 01-12).You can also specify the three-letter shorthand name or the full name of a month in English.Case-insensitive |
DD |
Day.It may contain 1 or 2 digits (1-31 or 01-31) |
HH |
Hour.It may contain 1 or 2 digits (0-23 or 00-23) |
mm |
Minutes.It may contain 1 or 2 digits (0-59 or 00-59) |
SS |
Seconds.It may contain 1 or 2 digits (0-59 or 00-59) |
NNNN |
Ten-thousandths of a second.It may contain from 1 to 4 digits (0-9999) |
p |
A date separator, any of permitted characters.Leading and trailing spaces are ignored.The choice of separator in a date decides whether the parser reads |
f |
Fractional seconds separator |
Important
|
Use of the complete specification of the year in the four-digit form — |
-- 1
UPDATE PEOPLE
SET AGECAT = 'SENIOR'
WHERE BIRTHDATE < DATE '1-Jan-1943';
-- 2
INSERT INTO APPOINTMENTS
(EMPLOYEE_ID, CLIENT_ID, APP_DATE, APP_TIME)
VALUES (973, 8804, DATE '1-Jan-2021' + 2, TIME '16:00');
-- 3
NEW.LASTMOD = TIMESTAMP '1-Jan-2021 16:00';
Tip
|
Although the Firebird datetime syntax is flexible, to avoid ambiguity we recommend using the ISO-8601 order (year-month-day), ‘ In short, use |