]> begriffs open source - ai-pg/blob - full-docs/txt/datetime-julian-dates.txt
Convert HTML docs to more streamlined TXT
[ai-pg] / full-docs / txt / datetime-julian-dates.txt
1
2 B.7. Julian Dates #
3
4    The Julian Date system is a method for numbering days. It is unrelated
5    to the Julian calendar, though it is confusingly named similarly to
6    that calendar. The Julian Date system was invented by the French
7    scholar Joseph Justus Scaliger (1540–1609) and probably takes its name
8    from Scaliger's father, the Italian scholar Julius Caesar Scaliger
9    (1484–1558).
10
11    In the Julian Date system, each day has a sequential number, starting
12    from JD 0 (which is sometimes called the Julian Date). JD 0 corresponds
13    to 1 January 4713 BC in the Julian calendar, or 24 November 4714 BC in
14    the Gregorian calendar. Julian Date counting is most often used by
15    astronomers for labeling their nightly observations, and therefore a
16    date runs from noon UTC to the next noon UTC, rather than from midnight
17    to midnight: JD 0 designates the 24 hours from noon UTC on 24 November
18    4714 BC to noon UTC on 25 November 4714 BC.
19
20    Although PostgreSQL supports Julian Date notation for input and output
21    of dates (and also uses Julian dates for some internal datetime
22    calculations), it does not observe the nicety of having dates run from
23    noon to noon. PostgreSQL treats a Julian Date as running from local
24    midnight to local midnight, the same as a normal date.
25
26    This definition does, however, provide a way to obtain the astronomical
27    definition when you need it: do the arithmetic in time zone UTC+12. For
28    example,
29 => SELECT extract(julian from '2021-06-23 7:00:00-04'::timestamptz at time zone
30 'UTC+12');
31            extract
32 ------------------------------
33  2459388.95833333333333333333
34 (1 row)
35 => SELECT extract(julian from '2021-06-23 8:00:00-04'::timestamptz at time zone
36 'UTC+12');
37                extract
38 --------------------------------------
39  2459389.0000000000000000000000000000
40 (1 row)
41 => SELECT extract(julian from date '2021-06-23');
42  extract
43 ---------
44  2459389
45 (1 row)