Skip to content

Commit 2bb31be

Browse files
committed
rlsnotes40 missed information on changes to datetime literal syntax
1 parent 4bd976f commit 2bb31be

File tree

1 file changed

+45
-0
lines changed

1 file changed

+45
-0
lines changed

src/docs/asciidoc/en/rlsnotes/rlsnotes40/_compatibility-40.adoc

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -204,6 +204,51 @@ Enforcement of the appropriate usage means that attempting to combine both becom
204204
Existing code where usage does not break the rule remains unaffected.
205205
Both `'NOW'` and `CAST('NOW' AS TIMESTAMP)` continue to work as before, as well as code that correctly uses the date/time prefixes with explicit literals, like `DATE '2019-02-20'`.
206206

207+
[#rnfb40-compat-datetime-string]
208+
==== Datetime Literal Syntax Changes
209+
210+
To avoid ambiguities with time zones, the datetime literal syntax -- also used when casting strings to datetime types -- had to be changed.
211+
In previous versions, any element of a datetime (e.g. year, minutes, etc.) could be separated by whitespace, `.`, `:`, `,`, `-`, and `/`.
212+
213+
The revised syntax is:
214+
215+
.Datetime Format Syntax
216+
[listing,subs="+quotes,attributes"]
217+
----
218+
<date_format> ::=
219+
[__YYYY__<p>{endsb}__MM__<p>__DD__
220+
| __MM__<p>__DD__[<p>{ __YYYY__ | __YY__ }]
221+
| __DD__<p>__MM__[<p>{ __YYYY__ | __YY__ }]
222+
223+
<time_format> ::= __HH__[:__mm__[:__SS__[<f>__NNNN__]]]
224+
225+
<timestamp_format> ::= <date_format> [<space> <time_format>]
226+
227+
<time_zone> ::=
228+
{ + | - }__HH__:__MM__
229+
| __time zone name (e.g. Europe/Berlin)__
230+
231+
<time_tz_format> ::= <time_format> [<space>] <time_zone>
232+
233+
<timestamp_tz_format> ::= <timestamp_format> [<space>] <time_zone>
234+
235+
<p> ::= whitespace | . | - | /
236+
<f> ::= : | .
237+
----
238+
239+
[NOTE]
240+
====
241+
The choice of the separator `<p>` in a date decides whether the parser reads `MM<p>DD` or `DD<p>MM`.
242+
====
243+
244+
[TIP]
245+
====
246+
Although the Firebird datetime syntax is still very flexible, to avoid ambiguity we recommend using the ISO-8601 order (year-month-day), '```-```' as the date separator, 4 digits for year, 2 digits for month, day, minute and second, and '```.```' as second.fractions separator.
247+
This format is also the only one defined in the SQL standard.
248+
249+
In short, use `TIMESTAMP '2021-05-03 04:05:00.1 +02:00'`, not `TIMESTAMP '3.5.21 4:5:0:1 +2:0'`.
250+
====
251+
207252
[[rnfb40-compat-sql-sequence-start-value]]
208253
=== Starting Value of Sequences
209254

0 commit comments

Comments
 (0)