2 $PostgreSQL: pgsql/doc/src/sgml/datetime.sgml,v 2.46 2005/06/15 00:34:08 momjian Exp $
5 <appendix id="datetime-appendix">
6 <title>Date/Time Support</title>
9 <productname>PostgreSQL</productname> uses an internal heuristic
10 parser for all date/time input support. Dates and times are input as
11 strings, and are broken up into distinct fields with a preliminary
12 determination of what kind of information may be in the
13 field. Each field is interpreted and either assigned a numeric
14 value, ignored, or rejected.
15 The parser contains internal lookup tables for all textual fields,
16 including months, days of the week, and time zones.
20 This appendix includes information on the content of these
21 lookup tables and describes the steps used by the parser to decode
26 <title>Date/Time Input Interpretation</title>
29 The date/time type inputs are all decoded using the following procedure.
35 Break the input string into tokens and categorize each token as
36 a string, time, time zone, or number.
42 If the numeric token contains a colon (<literal>:</>), this is
43 a time string. Include all subsequent digits and colons.
49 If the numeric token contains a dash (<literal>-</>), slash
50 (<literal>/</>), or two or more dots (<literal>.</>), this is
51 a date string which may have a text month.
57 If the token is numeric only, then it is either a single field
58 or an ISO 8601 concatenated date (e.g.,
59 <literal>19990113</literal> for January 13, 1999) or time
60 (e.g., <literal>141516</literal> for 14:15:16).
66 If the token starts with a plus (<literal>+</>) or minus
67 (<literal>-</>), then it is either a time zone or a special
76 If the token is a text string, match up with possible strings.
82 Do a binary-search table lookup for the token
83 as either a special string (e.g., <literal>today</literal>),
84 day (e.g., <literal>Thursday</literal>),
85 month (e.g., <literal>January</literal>),
86 or noise word (e.g., <literal>at</literal>, <literal>on</literal>).
90 Set field values and bit mask for fields.
91 For example, set year, month, day for <literal>today</literal>,
92 and additionally hour, minute, second for <literal>now</literal>.
98 If not found, do a similar binary-search table lookup to match
99 the token with a time zone.
105 If still not found, throw an error.
113 When the token is a number or number field:
119 If there are eight or six digits,
120 and if no other date fields have been previously read, then interpret
121 as a <quote>concatenated date</quote> (e.g.,
122 <literal>19990118</literal> or <literal>990118</literal>).
123 The interpretation is <literal>YYYYMMDD</> or <literal>YYMMDD</>.
129 If the token is three digits
130 and a year has already been read, then interpret as day of year.
136 If four or six digits and a year has already been read, then
137 interpret as a time (<literal>HHMM</> or <literal>HHMMSS</>).
143 If three or more digits and no date fields have yet been found,
144 interpret as a year (this forces yy-mm-dd ordering of the remaining
151 Otherwise the date field ordering is assumed to follow the
152 <varname>DateStyle</> setting: mm-dd-yy, dd-mm-yy, or yy-mm-dd.
153 Throw an error if a month or day field is found to be out of range.
161 If BC has been specified, negate the year and add one for
162 internal storage. (There is no year zero in the Gregorian
163 calendar, so numerically 1 BC becomes year zero.)
169 If BC was not specified, and if the year field was two digits in length,
170 then adjust the year to four digits. If the field is less than 70, then
171 add 2000, otherwise add 1900.
175 Gregorian years AD 1-99 may be entered by using 4 digits with leading
176 zeros (e.g., <literal>0099</> is AD 99). Previous versions of
177 <productname>PostgreSQL</productname> accepted years with three
178 digits and with single digits, but as of version 7.0 the rules have
179 been tightened up to reduce the possibility of ambiguity.
188 <sect1 id="datetime-keywords">
189 <title>Date/Time Key Words</title>
192 <xref linkend="datetime-month-table"> shows the tokens that are
193 recognized as names of months.
196 <table id="datetime-month-table">
197 <title>Month Names</title>
202 <entry>Abbreviations</entry>
207 <entry>January</entry>
211 <entry>February</entry>
235 <entry>August</entry>
239 <entry>September</entry>
240 <entry>Sep, Sept</entry>
243 <entry>October</entry>
247 <entry>November</entry>
251 <entry>December</entry>
259 <xref linkend="datetime-dow-table"> shows the tokens that are
260 recognized as names of days of the week.
263 <table id="datetime-dow-table">
264 <title>Day of the Week Names</title>
269 <entry>Abbreviations</entry>
274 <entry>Sunday</entry>
278 <entry>Monday</entry>
282 <entry>Tuesday</entry>
283 <entry>Tue, Tues</entry>
286 <entry>Wednesday</entry>
287 <entry>Wed, Weds</entry>
290 <entry>Thursday</entry>
291 <entry>Thu, Thur, Thurs</entry>
294 <entry>Friday</entry>
298 <entry>Saturday</entry>
306 <xref linkend="datetime-mod-table"> shows the tokens that serve
307 various modifier purposes.
310 <table id="datetime-mod-table">
311 <title>Date/Time Field Modifiers</title>
315 <entry>Identifier</entry>
316 <entry>Description</entry>
321 <entry><literal>ABSTIME</literal></entry>
322 <entry>Ignored</entry>
325 <entry><literal>AM</literal></entry>
326 <entry>Time is before 12:00</entry>
329 <entry><literal>AT</literal></entry>
330 <entry>Ignored</entry>
333 <entry><literal>JULIAN</>, <literal>JD</>, <literal>J</></entry>
334 <entry>Next field is Julian Day</entry>
337 <entry><literal>ON</literal></entry>
338 <entry>Ignored</entry>
341 <entry><literal>PM</literal></entry>
342 <entry>Time is on or after 12:00</entry>
345 <entry><literal>T</literal></entry>
346 <entry>Next field is time</entry>
353 The key word <literal>ABSTIME</literal> is ignored for historical
354 reasons: In very old releases of
355 <productname>PostgreSQL</productname>, invalid values of type <type>abstime</type>
356 were emitted as <literal>Invalid Abstime</literal>. This is no
357 longer the case however and this key word will likely be dropped in
362 <primary>time zone</primary>
363 <secondary>input abbreviations</secondary>
367 <xref linkend="datetime-timezone-input-table"> shows the time zone
368 abbreviations recognized by <productname>PostgreSQL</productname>
369 in date/time input values. Note that these names are <emphasis>not</>
370 necessarily used for date/time output — output is driven by the
371 official timezone abbreviation(s) associated with the currently selected
372 <xref linkend="guc-timezone"> parameter setting. (It is
373 likely that future releases will make some use of <varname>timezone</>
378 The table is organized by time zone offset from <acronym>UTC</>,
379 rather than alphabetically. This is intended to facilitate
380 matching local usage with recognized abbreviations for cases where
384 <table id="datetime-timezone-input-table">
385 <title>Time Zone Abbreviations for Input</title>
389 <entry>Time Zone</entry>
390 <entry>Offset from UTC</entry>
391 <entry>Description</entry>
397 <entry>+13:00</entry>
398 <entry>New Zealand Daylight-Saving Time</entry>
402 <entry>+12:00</entry>
403 <entry>International Date Line, East</entry>
407 <entry>+12:00</entry>
408 <entry>New Zealand Standard Time</entry>
412 <entry>+12:00</entry>
413 <entry>New Zealand Time</entry>
417 <entry>+11:00</entry>
418 <entry>Australia Eastern Summer Standard Time</entry>
422 <entry>+10:30</entry>
423 <entry>Central Australia Summer Standard Time</entry>
427 <entry>+10:30</entry>
428 <entry>Central Australia Daylight-Saving Time</entry>
432 <entry>+10:30</entry>
433 <entry>South Australian Daylight-Saving Time</entry>
437 <entry>+10:00</entry>
438 <entry>Australia Eastern Standard Time</entry>
442 <entry>+10:00</entry>
443 <entry>East Australian Standard Time</entry>
447 <entry>+10:00</entry>
448 <entry>Guam Standard Time, Russia zone 9</entry>
452 <entry>+10:00</entry>
453 <entry>Melbourne, Australia</entry>
457 <entry>+09:30</entry>
458 <entry>South Australia Standard Time</entry>
462 <entry>+09:30</entry>
463 <entry>Central Australia Standard Time</entry>
467 <entry>+09:00</entry>
468 <entry>Australia Western Summer Standard Time</entry>
472 <entry>+09:00</entry>
473 <entry>Japan Standard Time, Russia zone 8</entry>
477 <entry>+09:00</entry>
478 <entry>Korea Standard Time</entry>
482 <entry>+09:00</entry>
483 <entry>Kwajalein Time</entry>
487 <entry>+09:00</entry>
488 <entry>West Australian Daylight-Saving Time</entry>
492 <entry>+08:30</entry>
493 <entry>Moluccas Time</entry>
497 <entry>+08:00</entry>
498 <entry>Australia Western Standard Time</entry>
502 <entry>+08:00</entry>
503 <entry>China Coastal Time</entry>
507 <entry>+08:00</entry>
508 <entry>West Australian Daylight-Saving Time</entry>
512 <entry>+08:00</entry>
513 <entry>West Australian Standard Time</entry>
517 <entry>+07:30</entry>
518 <entry>Java Time</entry>
522 <entry>+07:00</entry>
523 <entry>Almaty Summer Time</entry>
527 <entry>+07:00</entry>
528 <entry>West Australian Standard Time</entry>
532 <entry>+07:00</entry>
533 <entry>Christmas (Island) Time</entry>
537 <entry>+06:30</entry>
538 <entry>Myanmar Time</entry>
542 <entry>+06:00</entry>
543 <entry>Almaty Time</entry>
547 <entry>+06:00</entry>
548 <entry>Mawson (Antarctica) Time</entry>
552 <entry>+05:00</entry>
553 <entry>Indian Chagos Time</entry>
557 <entry>+05:00</entry>
558 <entry>Maldives Island Time</entry>
562 <entry>+05:00</entry>
563 <entry>Kerguelen Time</entry>
567 <entry>+04:30</entry>
568 <entry>Afghanistan Time</entry>
572 <entry>+04:00</entry>
573 <entry>Antananarivo Summer Time</entry>
577 <entry>+04:00</entry>
578 <entry>Mauritius Island Time</entry>
582 <entry>+04:00</entry>
583 <entry>Reunion Island Time</entry>
587 <entry>+04:00</entry>
588 <entry>Mahe Island Time</entry>
591 <entry>IRT, IT</entry>
592 <entry>+03:30</entry>
593 <entry>Iran Time</entry>
597 <entry>+03:00</entry>
598 <entry>Antananarivo, Comoro Time</entry>
602 <entry>+03:00</entry>
603 <entry>Baghdad Time</entry>
606 <entry>EETDST</entry>
607 <entry>+03:00</entry>
608 <entry>Eastern Europe Daylight-Saving Time</entry>
612 <entry>+03:00</entry>
613 <entry>Hellas Mediterranean Time (?)</entry>
617 <entry>+02:00</entry>
618 <entry>British Double Summer Time</entry>
622 <entry>+02:00</entry>
623 <entry>Central European Summer Time</entry>
626 <entry>CETDST</entry>
627 <entry>+02:00</entry>
628 <entry>Central European Daylight-Saving Time</entry>
632 <entry>+02:00</entry>
633 <entry>Eastern European Time, Russia zone 1</entry>
637 <entry>+02:00</entry>
638 <entry>French Winter Time</entry>
642 <entry>+02:00</entry>
643 <entry>Israel Standard Time</entry>
647 <entry>+02:00</entry>
648 <entry>Middle European Summer Time</entry>
651 <entry>METDST</entry>
652 <entry>+02:00</entry>
653 <entry>Middle Europe Daylight-Saving Time</entry>
657 <entry>+02:00</entry>
658 <entry>Swedish Summer Time</entry>
662 <entry>+01:00</entry>
663 <entry>British Summer Time</entry>
667 <entry>+01:00</entry>
668 <entry>Central European Time</entry>
672 <entry>+01:00</entry>
673 <entry><foreignphrase>Dansk Normal Tid</foreignphrase></entry>
677 <entry>+01:00</entry>
678 <entry>French Summer Time</entry>
682 <entry>+01:00</entry>
683 <entry>Middle European Time</entry>
687 <entry>+01:00</entry>
688 <entry>Middle European Winter Time</entry>
692 <entry>+01:00</entry>
693 <entry><foreignphrase>Mitteleuropäische Zeit</></entry>
697 <entry>+01:00</entry>
698 <entry>Norway Standard Time</entry>
702 <entry>+01:00</entry>
703 <entry>Seychelles Time</entry>
707 <entry>+01:00</entry>
708 <entry>Swedish Winter Time</entry>
711 <entry>WETDST</entry>
712 <entry>+01:00</entry>
713 <entry>Western European Daylight-Saving Time</entry>
718 <entry>Greenwich Mean Time</entry>
723 <entry>Universal Time</entry>
728 <entry>Universal Coordinated Time</entry>
733 <entry>Same as UTC</entry>
738 <entry>Same as UTC</entry>
743 <entry>Western European Time</entry>
747 <entry>-01:00</entry>
748 <entry>West Africa Time</entry>
752 <entry>-01:00</entry>
753 <entry>Fernando de Noronha Summer Time</entry>
757 <entry>-02:00</entry>
758 <entry>Fernando de Noronha Time</entry>
762 <entry>-02:00</entry>
763 <entry>Brasilia Summer Time</entry>
767 <entry>-02:30</entry>
768 <entry>Newfoundland Daylight-Saving Time</entry>
772 <entry>-03:00</entry>
773 <entry>Atlantic Daylight-Saving Time</entry>
777 <entry>-03:00</entry>
778 <entry>(unknown)</entry>
782 <entry>-03:00</entry>
783 <entry>Brasilia Time</entry>
787 <entry>-03:30</entry>
788 <entry>Newfoundland Standard Time</entry>
792 <entry>-03:30</entry>
793 <entry>Newfoundland Standard Time</entry>
797 <entry>-04:00</entry>
798 <entry>Atlantic Standard Time (Canada)</entry>
802 <entry>-04:00</entry>
803 <entry>Atlantic/Porto Acre Summer Time</entry>
807 <entry>-04:00</entry>
808 <entry>Eastern Daylight-Saving Time</entry>
813 <entry>-04:00</entry>
814 <entry>GMT +4 hours</entry>
819 <entry>-05:00</entry>
820 <entry>Atlantic/Porto Acre Standard Time</entry>
824 <entry>-05:00</entry>
825 <entry>Central Daylight-Saving Time</entry>
829 <entry>-05:00</entry>
830 <entry>Eastern Standard Time</entry>
835 <entry>-05:00</entry>
836 <entry>GMT +5 hours</entry>
841 <entry>-06:00</entry>
842 <entry>Central Standard Time</entry>
846 <entry>-06:00</entry>
847 <entry>Mountain Daylight-Saving Time</entry>
852 <entry>-06:00</entry>
853 <entry>GMT +6 hours</entry>
858 <entry>-07:00</entry>
859 <entry>Mountain Standard Time</entry>
863 <entry>-07:00</entry>
864 <entry>Pacific Daylight-Saving Time</entry>
868 <entry>-08:00</entry>
869 <entry>Alaska Daylight-Saving Time</entry>
873 <entry>-08:00</entry>
874 <entry>Pacific Standard Time</entry>
878 <entry>-08:00</entry>
879 <entry>Yukon Daylight-Saving Time</entry>
883 <entry>-09:00</entry>
884 <entry>Alaska Standard Time</entry>
888 <entry>-09:00</entry>
889 <entry>Hawaii/Alaska Daylight-Saving Time</entry>
893 <entry>-09:00</entry>
894 <entry>Yukon Standard Time</entry>
898 <entry>-09:30</entry>
899 <entry>Marquesas Time</entry>
903 <entry>-10:00</entry>
904 <entry>Alaska/Hawaii Standard Time</entry>
908 <entry>-10:00</entry>
909 <entry>Hawaii Standard Time</entry>
913 <entry>-10:00</entry>
914 <entry>Central Alaska Time</entry>
918 <entry>-11:00</entry>
919 <entry>Nome Time</entry>
923 <entry>-12:00</entry>
924 <entry>International Date Line, West</entry>
931 <title>Australian Time Zones</title>
934 There are three naming conflicts between Australian time zone
935 names and time zone names commonly used in North and South America:
936 <literal>ACST</literal>, <literal>CST</literal>, and
937 <literal>EST</literal>. If the run-time option
938 <varname>australian_timezones</varname> is set to true then
939 <literal>ACST</literal>, <literal>CST</literal>,
940 <literal>EST</literal>, and <literal>SAT</literal> are interpreted
941 as Australian time zone names, as shown in <xref
942 linkend="datetime-oztz-table">. If it is false (which is the
943 default), then <literal>ACST</literal>, <literal>CST</literal>,
944 and <literal>EST</literal> are taken as American time zone names,
945 and <literal>SAT</literal> is interpreted as a noise word
950 <table id="datetime-oztz-table">
951 <title>Australian Time Zone Abbreviations for Input</title>
955 <entry>Time Zone</entry>
956 <entry>Offset from UTC</entry>
957 <entry>Description</entry>
963 <entry>+09:30</entry>
964 <entry>Central Australia Standard Time</entry>
968 <entry>+10:30</entry>
969 <entry>Australian Central Standard Time</entry>
973 <entry>+10:00</entry>
974 <entry>Australian Eastern Standard Time</entry>
978 <entry>+09:30</entry>
979 <entry>South Australian Standard Time</entry>
986 <primary>time zone</primary>
987 <secondary>configuration names</secondary>
991 <xref linkend="datetime-timezone-set-table"> shows the time zone
992 names recognized by <productname>PostgreSQL</productname> as valid
993 settings for the <xref linkend="guc-timezone"> parameter, and as
994 parameters to the <literal>AT TIME ZONE function</> (see
995 <xref linkend="functions-datetime-zoneconvert">). Note that
996 these names are conceptually as well as practically different from
997 the names shown in <xref linkend="datetime-timezone-input-table">:
998 most of these names imply a local daylight-savings time rule, whereas
999 the former names each represent just a fixed offset from UTC.
1003 In many cases there are several equivalent names for the same zone.
1004 These are listed on the same line. The table is primarily sorted
1005 by the name of the principal city of the zone.
1008 <table id="datetime-timezone-set-table">
1009 <title>Time Zone Names for Setting <varname>timezone</> and <literal>AT TIME ZONE</></title>
1013 <entry>Time Zone</entry>
1018 <entry>Africa/Abidjan</entry>
1021 <entry>Africa/Accra</entry>
1024 <entry>Africa/Addis_Ababa</entry>
1027 <entry>Africa/Algiers</entry>
1030 <entry>Africa/Asmera</entry>
1033 <entry>Africa/Bamako</entry>
1036 <entry>Africa/Bangui</entry>
1039 <entry>Africa/Banjul</entry>
1042 <entry>Africa/Bissau</entry>
1045 <entry>Africa/Blantyre</entry>
1048 <entry>Africa/Brazzaville</entry>
1051 <entry>Africa/Bujumbura</entry>
1054 <entry>Africa/Cairo Egypt</entry>
1057 <entry>Africa/Casablanca</entry>
1060 <entry>Africa/Ceuta</entry>
1063 <entry>Africa/Conakry</entry>
1066 <entry>Africa/Dakar</entry>
1069 <entry>Africa/Dar_es_Salaam</entry>
1072 <entry>Africa/Djibouti</entry>
1075 <entry>Africa/Douala</entry>
1078 <entry>Africa/El_Aaiun</entry>
1081 <entry>Africa/Freetown</entry>
1084 <entry>Africa/Gaborone</entry>
1087 <entry>Africa/Harare</entry>
1090 <entry>Africa/Johannesburg</entry>
1093 <entry>Africa/Kampala</entry>
1096 <entry>Africa/Khartoum</entry>
1099 <entry>Africa/Kigali</entry>
1102 <entry>Africa/Kinshasa</entry>
1105 <entry>Africa/Lagos</entry>
1108 <entry>Africa/Libreville</entry>
1111 <entry>Africa/Lome</entry>
1114 <entry>Africa/Luanda</entry>
1117 <entry>Africa/Lubumbashi</entry>
1120 <entry>Africa/Lusaka</entry>
1123 <entry>Africa/Malabo</entry>
1126 <entry>Africa/Maputo</entry>
1129 <entry>Africa/Maseru</entry>
1132 <entry>Africa/Mbabane</entry>
1135 <entry>Africa/Mogadishu</entry>
1138 <entry>Africa/Monrovia</entry>
1141 <entry>Africa/Nairobi</entry>
1144 <entry>Africa/Ndjamena</entry>
1147 <entry>Africa/Niamey</entry>
1150 <entry>Africa/Nouakchott</entry>
1153 <entry>Africa/Ouagadougou</entry>
1156 <entry>Africa/Porto-Novo</entry>
1159 <entry>Africa/Sao_Tome</entry>
1162 <entry>Africa/Timbuktu</entry>
1165 <entry>Africa/Tripoli Libya</entry>
1168 <entry>Africa/Tunis</entry>
1171 <entry>Africa/Windhoek</entry>
1174 <entry>America/Adak America/Atka US/Aleutian</entry>
1177 <entry>America/Anchorage SystemV/YST9YDT US/Alaska</entry>
1180 <entry>America/Anguilla</entry>
1183 <entry>America/Antigua</entry>
1186 <entry>America/Araguaina</entry>
1189 <entry>America/Aruba</entry>
1192 <entry>America/Asuncion</entry>
1195 <entry>America/Bahia</entry>
1198 <entry>America/Barbados</entry>
1201 <entry>America/Belem</entry>
1204 <entry>America/Belize</entry>
1207 <entry>America/Boa_Vista</entry>
1210 <entry>America/Bogota</entry>
1213 <entry>America/Boise</entry>
1216 <entry>America/Buenos_Aires</entry>
1219 <entry>America/Cambridge_Bay</entry>
1222 <entry>America/Campo_Grande</entry>
1225 <entry>America/Cancun</entry>
1228 <entry>America/Caracas</entry>
1231 <entry>America/Catamarca</entry>
1234 <entry>America/Cayenne</entry>
1237 <entry>America/Cayman</entry>
1240 <entry>America/Chicago CST6CDT SystemV/CST6CDT US/Central</entry>
1243 <entry>America/Chihuahua</entry>
1246 <entry>America/Cordoba America/Rosario</entry>
1249 <entry>America/Costa_Rica</entry>
1252 <entry>America/Cuiaba</entry>
1255 <entry>America/Curacao</entry>
1258 <entry>America/Danmarkshavn</entry>
1261 <entry>America/Dawson</entry>
1264 <entry>America/Dawson_Creek</entry>
1267 <entry>America/Denver MST7MDT SystemV/MST7MDT US/Mountain America/Shiprock Navajo</entry>
1270 <entry>America/Detroit US/Michigan</entry>
1273 <entry>America/Dominica</entry>
1276 <entry>America/Edmonton Canada/Mountain</entry>
1279 <entry>America/Eirunepe</entry>
1282 <entry>America/El_Salvador</entry>
1285 <entry>America/Ensenada America/Tijuana Mexico/BajaNorte</entry>
1288 <entry>America/Fortaleza</entry>
1291 <entry>America/Glace_Bay</entry>
1294 <entry>America/Godthab</entry>
1297 <entry>America/Goose_Bay</entry>
1300 <entry>America/Grand_Turk</entry>
1303 <entry>America/Grenada</entry>
1306 <entry>America/Guadeloupe</entry>
1309 <entry>America/Guatemala</entry>
1312 <entry>America/Guayaquil</entry>
1315 <entry>America/Guyana</entry>
1318 <entry>America/Halifax Canada/Atlantic SystemV/AST4ADT</entry>
1321 <entry>America/Havana Cuba</entry>
1324 <entry>America/Hermosillo</entry>
1327 <entry>America/Indiana/Indianapolis America/Indianapolis America/Fort_Wayne EST SystemV/EST5 US/East-Indiana</entry>
1330 <entry>America/Indiana/Knox America/Knox_IN US/Indiana-Starke</entry>
1333 <entry>America/Indiana/Marengo</entry>
1336 <entry>America/Indiana/Vevay</entry>
1339 <entry>America/Inuvik</entry>
1342 <entry>America/Iqaluit</entry>
1345 <entry>America/Jamaica Jamaica</entry>
1348 <entry>America/Jujuy</entry>
1351 <entry>America/Juneau</entry>
1354 <entry>America/Kentucky/Louisville America/Louisville</entry>
1357 <entry>America/Kentucky/Monticello</entry>
1360 <entry>America/La_Paz</entry>
1363 <entry>America/Lima</entry>
1366 <entry>America/Los_Angeles PST8PDT SystemV/PST8PDT US/Pacific US/Pacific-New</entry>
1369 <entry>America/Maceio</entry>
1372 <entry>America/Managua</entry>
1375 <entry>America/Manaus Brazil/West</entry>
1378 <entry>America/Martinique</entry>
1381 <entry>America/Mazatlan Mexico/BajaSur</entry>
1384 <entry>America/Mendoza</entry>
1387 <entry>America/Menominee</entry>
1390 <entry>America/Merida</entry>
1393 <entry>America/Mexico_City Mexico/General</entry>
1396 <entry>America/Miquelon</entry>
1399 <entry>America/Monterrey</entry>
1402 <entry>America/Montevideo</entry>
1405 <entry>America/Montreal</entry>
1408 <entry>America/Montserrat</entry>
1411 <entry>America/Nassau</entry>
1414 <entry>America/New_York EST5EDT SystemV/EST5EDT US/Eastern</entry>
1417 <entry>America/Nipigon</entry>
1420 <entry>America/Nome</entry>
1423 <entry>America/Noronha Brazil/DeNoronha</entry>
1426 <entry>America/North_Dakota/Center</entry>
1429 <entry>America/Panama</entry>
1432 <entry>America/Pangnirtung</entry>
1435 <entry>America/Paramaribo</entry>
1438 <entry>America/Phoenix MST SystemV/MST7 US/Arizona</entry>
1441 <entry>America/Port-au-Prince</entry>
1444 <entry>America/Port_of_Spain</entry>
1447 <entry>America/Porto_Acre America/Rio_Branco Brazil/Acre</entry>
1450 <entry>America/Porto_Velho</entry>
1453 <entry>America/Puerto_Rico SystemV/AST4</entry>
1456 <entry>America/Rainy_River</entry>
1459 <entry>America/Rankin_Inlet</entry>
1462 <entry>America/Recife</entry>
1465 <entry>America/Regina Canada/East-Saskatchewan Canada/Saskatchewan SystemV/CST6</entry>
1468 <entry>America/Santiago Chile/Continental</entry>
1471 <entry>America/Santo_Domingo</entry>
1474 <entry>America/Sao_Paulo Brazil/East</entry>
1477 <entry>America/Scoresbysund</entry>
1480 <entry>America/St_Johns Canada/Newfoundland</entry>
1483 <entry>America/St_Kitts</entry>
1486 <entry>America/St_Lucia</entry>
1489 <entry>America/St_Thomas America/Virgin</entry>
1492 <entry>America/St_Vincent</entry>
1495 <entry>America/Swift_Current</entry>
1498 <entry>America/Tegucigalpa</entry>
1501 <entry>America/Thule</entry>
1504 <entry>America/Thunder_Bay</entry>
1507 <entry>America/Toronto Canada/Eastern</entry>
1510 <entry>America/Tortola</entry>
1513 <entry>America/Vancouver Canada/Pacific</entry>
1516 <entry>America/Whitehorse Canada/Yukon</entry>
1519 <entry>America/Winnipeg Canada/Central</entry>
1522 <entry>America/Yakutat</entry>
1525 <entry>America/Yellowknife</entry>
1528 <entry>Antarctica/Casey</entry>
1531 <entry>Antarctica/Davis</entry>
1534 <entry>Antarctica/DumontDUrville</entry>
1537 <entry>Antarctica/Mawson</entry>
1540 <entry>Antarctica/McMurdo Antarctica/South_Pole</entry>
1543 <entry>Antarctica/Palmer</entry>
1546 <entry>Antarctica/Rothera</entry>
1549 <entry>Antarctica/Syowa</entry>
1552 <entry>Antarctica/Vostok</entry>
1555 <entry>Asia/Aden</entry>
1558 <entry>Asia/Almaty</entry>
1561 <entry>Asia/Amman</entry>
1564 <entry>Asia/Anadyr</entry>
1567 <entry>Asia/Aqtau</entry>
1570 <entry>Asia/Aqtobe</entry>
1573 <entry>Asia/Ashgabat Asia/Ashkhabad</entry>
1576 <entry>Asia/Baghdad</entry>
1579 <entry>Asia/Bahrain</entry>
1582 <entry>Asia/Baku</entry>
1585 <entry>Asia/Bangkok</entry>
1588 <entry>Asia/Beirut</entry>
1591 <entry>Asia/Bishkek</entry>
1594 <entry>Asia/Brunei</entry>
1597 <entry>Asia/Calcutta</entry>
1600 <entry>Asia/Choibalsan</entry>
1603 <entry>Asia/Chongqing Asia/Chungking</entry>
1606 <entry>Asia/Colombo</entry>
1609 <entry>Asia/Dacca Asia/Dhaka</entry>
1612 <entry>Asia/Damascus</entry>
1615 <entry>Asia/Dili</entry>
1618 <entry>Asia/Dubai</entry>
1621 <entry>Asia/Dushanbe</entry>
1624 <entry>Asia/Gaza</entry>
1627 <entry>Asia/Harbin</entry>
1630 <entry>Asia/Hong_Kong Hongkong</entry>
1633 <entry>Asia/Hovd</entry>
1636 <entry>Asia/Irkutsk</entry>
1639 <entry>Asia/Jakarta</entry>
1642 <entry>Asia/Jayapura</entry>
1645 <entry>Asia/Jerusalem Asia/Tel_Aviv Israel</entry>
1648 <entry>Asia/Kabul</entry>
1651 <entry>Asia/Kamchatka</entry>
1654 <entry>Asia/Karachi</entry>
1657 <entry>Asia/Kashgar</entry>
1660 <entry>Asia/Katmandu</entry>
1663 <entry>Asia/Krasnoyarsk</entry>
1666 <entry>Asia/Kuala_Lumpur</entry>
1669 <entry>Asia/Kuching</entry>
1672 <entry>Asia/Kuwait</entry>
1675 <entry>Asia/Macao Asia/Macau</entry>
1678 <entry>Asia/Magadan</entry>
1681 <entry>Asia/Makassar Asia/Ujung_Pandang</entry>
1684 <entry>Asia/Manila</entry>
1687 <entry>Asia/Muscat</entry>
1690 <entry>Asia/Nicosia Europe/Nicosia</entry>
1693 <entry>Asia/Novosibirsk</entry>
1696 <entry>Asia/Omsk</entry>
1699 <entry>Asia/Oral</entry>
1702 <entry>Asia/Phnom_Penh</entry>
1705 <entry>Asia/Pontianak</entry>
1708 <entry>Asia/Pyongyang</entry>
1711 <entry>Asia/Qatar</entry>
1714 <entry>Asia/Qyzylorda</entry>
1717 <entry>Asia/Rangoon</entry>
1720 <entry>Asia/Riyadh</entry>
1723 <entry>Asia/Riyadh87 Mideast/Riyadh87</entry>
1726 <entry>Asia/Riyadh88 Mideast/Riyadh88</entry>
1729 <entry>Asia/Riyadh89 Mideast/Riyadh89</entry>
1732 <entry>Asia/Saigon</entry>
1735 <entry>Asia/Sakhalin</entry>
1738 <entry>Asia/Samarkand</entry>
1741 <entry>Asia/Seoul ROK</entry>
1744 <entry>Asia/Shanghai PRC</entry>
1747 <entry>Asia/Singapore Singapore</entry>
1750 <entry>Asia/Taipei ROC</entry>
1753 <entry>Asia/Tashkent</entry>
1756 <entry>Asia/Tbilisi</entry>
1759 <entry>Asia/Tehran Iran</entry>
1762 <entry>Asia/Thimbu Asia/Thimphu</entry>
1765 <entry>Asia/Tokyo Japan</entry>
1768 <entry>Asia/Ulaanbaatar Asia/Ulan_Bator</entry>
1771 <entry>Asia/Urumqi</entry>
1774 <entry>Asia/Vientiane</entry>
1777 <entry>Asia/Vladivostok</entry>
1780 <entry>Asia/Yakutsk</entry>
1783 <entry>Asia/Yekaterinburg</entry>
1786 <entry>Asia/Yerevan</entry>
1789 <entry>Atlantic/Azores</entry>
1792 <entry>Atlantic/Bermuda</entry>
1795 <entry>Atlantic/Canary</entry>
1798 <entry>Atlantic/Cape_Verde</entry>
1801 <entry>Atlantic/Faeroe</entry>
1804 <entry>Atlantic/Madeira</entry>
1807 <entry>Atlantic/Reykjavik Iceland</entry>
1810 <entry>Atlantic/South_Georgia</entry>
1813 <entry>Atlantic/St_Helena</entry>
1816 <entry>Atlantic/Stanley</entry>
1819 <entry>Australia/ACT Australia/Canberra Australia/NSW Australia/Sydney</entry>
1822 <entry>Australia/Adelaide Australia/South</entry>
1825 <entry>Australia/Brisbane Australia/Queensland</entry>
1828 <entry>Australia/Broken_Hill Australia/Yancowinna</entry>
1831 <entry>Australia/Darwin Australia/North</entry>
1834 <entry>Australia/Hobart Australia/Tasmania</entry>
1837 <entry>Australia/LHI Australia/Lord_Howe</entry>
1840 <entry>Australia/Lindeman</entry>
1843 <entry>Australia/Melbourne Australia/Victoria</entry>
1846 <entry>Australia/Perth Australia/West</entry>
1855 <entry>Etc/GMT+1</entry>
1858 <entry>Etc/GMT+2</entry>
1861 <entry>Etc/GMT+3</entry>
1864 <entry>Etc/GMT+4</entry>
1867 <entry>Etc/GMT+5</entry>
1870 <entry>Etc/GMT+6</entry>
1873 <entry>Etc/GMT+7</entry>
1876 <entry>Etc/GMT+8</entry>
1879 <entry>Etc/GMT+9</entry>
1882 <entry>Etc/GMT+10</entry>
1885 <entry>Etc/GMT+11</entry>
1888 <entry>Etc/GMT+12</entry>
1891 <entry>Etc/GMT-1</entry>
1894 <entry>Etc/GMT-2</entry>
1897 <entry>Etc/GMT-3</entry>
1900 <entry>Etc/GMT-4</entry>
1903 <entry>Etc/GMT-5</entry>
1906 <entry>Etc/GMT-6</entry>
1909 <entry>Etc/GMT-7</entry>
1912 <entry>Etc/GMT-8</entry>
1915 <entry>Etc/GMT-9</entry>
1918 <entry>Etc/GMT-10</entry>
1921 <entry>Etc/GMT-11</entry>
1924 <entry>Etc/GMT-12</entry>
1927 <entry>Etc/GMT-13</entry>
1930 <entry>Etc/GMT-14</entry>
1933 <entry>Europe/Amsterdam</entry>
1936 <entry>Europe/Andorra</entry>
1939 <entry>Europe/Athens</entry>
1942 <entry>Europe/Belfast</entry>
1945 <entry>Europe/Belgrade Europe/Ljubljana Europe/Sarajevo Europe/Skopje Europe/Zagreb</entry>
1948 <entry>Europe/Berlin</entry>
1951 <entry>Europe/Brussels</entry>
1954 <entry>Europe/Bucharest</entry>
1957 <entry>Europe/Budapest</entry>
1960 <entry>Europe/Chisinau Europe/Tiraspol</entry>
1963 <entry>Europe/Copenhagen</entry>
1966 <entry>Europe/Dublin Eire</entry>
1969 <entry>Europe/Gibraltar</entry>
1972 <entry>Europe/Helsinki</entry>
1975 <entry>Europe/Istanbul Asia/Istanbul Turkey</entry>
1978 <entry>Europe/Kaliningrad</entry>
1981 <entry>Europe/Kiev</entry>
1984 <entry>Europe/Lisbon Portugal</entry>
1987 <entry>Europe/London GB GB-Eire</entry>
1990 <entry>Europe/Luxembourg</entry>
1993 <entry>Europe/Madrid</entry>
1996 <entry>Europe/Malta</entry>
1999 <entry>Europe/Minsk</entry>
2002 <entry>Europe/Monaco</entry>
2005 <entry>Europe/Moscow W-SU</entry>
2008 <entry>Europe/Oslo Arctic/Longyearbyen Atlantic/Jan_Mayen</entry>
2011 <entry>Europe/Paris</entry>
2014 <entry>Europe/Prague Europe/Bratislava</entry>
2017 <entry>Europe/Riga</entry>
2020 <entry>Europe/Rome Europe/San_Marino Europe/Vatican</entry>
2023 <entry>Europe/Samara</entry>
2026 <entry>Europe/Simferopol</entry>
2029 <entry>Europe/Sofia</entry>
2032 <entry>Europe/Stockholm</entry>
2035 <entry>Europe/Tallinn</entry>
2038 <entry>Europe/Tirane</entry>
2041 <entry>Europe/Uzhgorod</entry>
2044 <entry>Europe/Vaduz</entry>
2047 <entry>Europe/Vienna</entry>
2050 <entry>Europe/Vilnius</entry>
2053 <entry>Europe/Warsaw Poland</entry>
2056 <entry>Europe/Zaporozhye</entry>
2059 <entry>Europe/Zurich</entry>
2062 <entry>Factory</entry>
2065 <entry>GMT GMT+0 GMT-0 GMT0 Greenwich Etc/GMT Etc/GMT+0 Etc/GMT-0 Etc/GMT0 Etc/Greenwich</entry>
2068 <entry>Indian/Antananarivo</entry>
2071 <entry>Indian/Chagos</entry>
2074 <entry>Indian/Christmas</entry>
2077 <entry>Indian/Cocos</entry>
2080 <entry>Indian/Comoro</entry>
2083 <entry>Indian/Kerguelen</entry>
2086 <entry>Indian/Mahe</entry>
2089 <entry>Indian/Maldives</entry>
2092 <entry>Indian/Mauritius</entry>
2095 <entry>Indian/Mayotte</entry>
2098 <entry>Indian/Reunion</entry>
2104 <entry>Pacific/Apia</entry>
2107 <entry>Pacific/Auckland NZ</entry>
2110 <entry>Pacific/Chatham NZ-CHAT</entry>
2113 <entry>Pacific/Easter Chile/EasterIsland</entry>
2116 <entry>Pacific/Efate</entry>
2119 <entry>Pacific/Enderbury</entry>
2122 <entry>Pacific/Fakaofo</entry>
2125 <entry>Pacific/Fiji</entry>
2128 <entry>Pacific/Funafuti</entry>
2131 <entry>Pacific/Galapagos</entry>
2134 <entry>Pacific/Gambier SystemV/YST9</entry>
2137 <entry>Pacific/Guadalcanal</entry>
2140 <entry>Pacific/Guam</entry>
2143 <entry>Pacific/Honolulu HST SystemV/HST10 US/Hawaii</entry>
2146 <entry>Pacific/Johnston</entry>
2149 <entry>Pacific/Kiritimati</entry>
2152 <entry>Pacific/Kosrae</entry>
2155 <entry>Pacific/Kwajalein Kwajalein</entry>
2158 <entry>Pacific/Majuro</entry>
2161 <entry>Pacific/Marquesas</entry>
2164 <entry>Pacific/Midway</entry>
2167 <entry>Pacific/Nauru</entry>
2170 <entry>Pacific/Niue</entry>
2173 <entry>Pacific/Norfolk</entry>
2176 <entry>Pacific/Noumea</entry>
2179 <entry>Pacific/Pago_Pago Pacific/Samoa US/Samoa</entry>
2182 <entry>Pacific/Palau</entry>
2185 <entry>Pacific/Pitcairn SystemV/PST8</entry>
2188 <entry>Pacific/Ponape</entry>
2191 <entry>Pacific/Port_Moresby</entry>
2194 <entry>Pacific/Rarotonga</entry>
2197 <entry>Pacific/Saipan</entry>
2200 <entry>Pacific/Tahiti</entry>
2203 <entry>Pacific/Tarawa</entry>
2206 <entry>Pacific/Tongatapu</entry>
2209 <entry>Pacific/Truk</entry>
2212 <entry>Pacific/Wake</entry>
2215 <entry>Pacific/Wallis</entry>
2218 <entry>Pacific/Yap</entry>
2221 <entry>UCT Etc/UCT</entry>
2224 <entry>UTC Universal Zulu Etc/UTC Etc/Universal Etc/Zulu</entry>
2234 In addition to the names listed in the table,
2235 <productname>PostgreSQL</productname> will accept time zone names of the
2236 form <replaceable>STD</><replaceable>offset</> or
2237 <replaceable>STD</><replaceable>offset</><replaceable>DST</>, where
2238 <replaceable>STD</> is a zone abbreviation, <replaceable>offset</> is a
2239 numeric offset in hours west from UTC, and <replaceable>DST</> is an
2240 optional daylight-savings zone abbreviation, assumed to stand for one hour
2241 ahead of the given offset. For example, if <literal>EST5EDT</> were not
2242 already a recognized zone name, it would be accepted and would be
2243 functionally equivalent to USA East Coast time. When a daylight-savings
2244 zone name is present, it is assumed to be used according to USA time zone
2245 rules, so this feature is of limited use outside North America.
2246 One should also be wary that this provision can lead to
2247 silently accepting bogus input, since there is no check on the
2248 reasonableness of the zone abbreviations. For example,
2249 <literal>SET TIMEZONE TO FOOBAR0</> will work, leaving the system
2250 effectively using a rather peculiar abbreviation for GMT.
2255 <sect1 id="datetime-units-history">
2256 <title>History of Units</title>
2259 The Julian Date was invented by the French scholar
2260 Joseph Justus Scaliger (1540-1609)
2261 and probably takes its name from Scaliger's father,
2262 the Italian scholar Julius Caesar Scaliger (1484-1558).
2263 Astronomers have used the Julian period to assign a unique number to
2264 every day since 1 January 4713 BC. This is the so-called Julian Date
2265 (JD). JD 0 designates the 24 hours from noon UTC on 1 January 4713 BC
2266 to noon UTC on 2 January 4713 BC.
2270 The <quote>Julian Date</quote> is different from the <quote>Julian
2271 Calendar</quote>. The Julian calendar
2272 was introduced by Julius Caesar in 45 BC. It was in common use
2273 until the year 1582, when countries started changing to the Gregorian
2274 calendar. In the Julian calendar, the tropical year is
2275 approximated as 365 1/4 days = 365.25 days. This gives an error of
2276 about 1 day in 128 years.
2280 The accumulating calendar error prompted
2281 Pope Gregory XIII to reform the calendar in accordance with
2282 instructions from the Council of Trent.
2283 In the Gregorian calendar, the tropical year is approximated as
2284 365 + 97 / 400 days = 365.2425 days. Thus it takes approximately 3300
2285 years for the tropical year to shift one day with respect to the
2290 The approximation 365+97/400 is achieved by having 97 leap years
2291 every 400 years, using the following rules:
2295 Every year divisible by 4 is a leap year.
2298 However, every year divisible by 100 is not a leap year.
2301 However, every year divisible by 400 is a leap year after all.
2305 So, 1700, 1800, 1900, 2100, and 2200 are not leap years. But 1600,
2306 2000, and 2400 are leap years.
2308 By contrast, in the older Julian calendar all years divisible by 4 are leap
2313 The papal bull of February 1582 decreed that 10 days should be dropped
2314 from October 1582 so that 15 October should follow immediately after
2316 This was observed in Italy, Poland, Portugal, and Spain. Other Catholic
2317 countries followed shortly after, but Protestant countries were
2318 reluctant to change, and the Greek orthodox countries didn't change
2319 until the start of the 20th century.
2321 The reform was observed by Great Britain and Dominions (including what is
2322 now the USA) in 1752.
2323 Thus 2 September 1752 was followed by 14 September 1752.
2325 This is why Unix systems have the <command>cal</command> program
2326 produce the following:
2329 $ <userinput>cal 9 1752</userinput>
2333 17 18 19 20 21 22 23
2334 24 25 26 27 28 29 30
2340 The SQL standard states that <quote>Within the definition of a
2341 <quote>datetime literal</quote>, the <quote>datetime
2342 value</quote>s are constrained by the natural rules for dates and
2343 times according to the Gregorian calendar</quote>. Dates between
2344 1752-09-03 and 1752-09-13, although eliminated in some countries
2345 by Papal fiat, conform to <quote>natural rules</quote> and are
2351 Different calendars have been developed in various parts of the
2352 world, many predating the Gregorian system.
2355 the beginnings of the Chinese calendar can be traced back to the 14th
2356 century BC. Legend has it that the Emperor Huangdi invented the
2357 calendar in 2637 BC.
2359 The People's Republic of China uses the Gregorian calendar
2360 for civil purposes. The Chinese calendar is used for determining
2366 <!-- Keep this comment at the end of the file
2371 sgml-minimize-attributes:nil
2372 sgml-always-quote-attributes:t
2375 sgml-parent-document:nil
2376 sgml-default-dtd-file:"./reference.ced"
2377 sgml-exposed-tags:nil
2378 sgml-local-catalogs:("/usr/lib/sgml/catalog")
2379 sgml-local-ecat-files:nil