| Server IP : 94.16.115.136 / Your IP : 216.73.217.106 Web Server : Apache/2.4.52 (Ubuntu) System : Linux rogerrabbit 5.15.0-185-generic #195-Ubuntu SMP Fri Jun 19 17:11:50 UTC 2026 x86_64 User : bkillingseder ( 1001) PHP Version : 8.1.2-1ubuntu2.25 Disable Function : NONE MySQL : OFF | cURL : ON | WGET : ON | Perl : ON | Python : OFF | Sudo : ON | Pkexec : ON Directory : /snap/postgresql10/current/usr/share/doc/postgresql/html/ |
Upload File : |
<?xml version="1.0" encoding="UTF-8" standalone="no"?>
<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"><html xmlns="http://www.w3.org/1999/xhtml"><head><meta http-equiv="Content-Type" content="text/html; charset=UTF-8" /><title>B.1. Date/Time Input Interpretation</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets V1.79.1" /><link rel="prev" href="datetime-appendix.html" title="Appendix B. Date/Time Support" /><link rel="next" href="datetime-keywords.html" title="B.2. Date/Time Key Words" /></head><body><div xmlns="http://www.w3.org/TR/xhtml1/transitional" class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">B.1. Date/Time Input Interpretation</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="datetime-appendix.html" title="Appendix B. Date/Time Support">Prev</a> </td><td width="10%" align="left"><a accesskey="u" href="datetime-appendix.html" title="Appendix B. Date/Time Support">Up</a></td><th width="60%" align="center">Appendix B. Date/Time Support</th><td width="10%" align="right"><a accesskey="h" href="index.html" title="PostgreSQL 10.4 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="datetime-keywords.html" title="B.2. Date/Time Key Words">Next</a></td></tr></table><hr></hr></div><div class="sect1" id="DATETIME-INPUT-RULES"><div class="titlepage"><div><div><h2 class="title" style="clear: both">B.1. Date/Time Input Interpretation</h2></div></div></div><p> The date/time type inputs are all decoded using the following procedure.
</p><div class="procedure"><ol class="procedure" type="1"><li class="step"><p> Break the input string into tokens and categorize each token as
a string, time, time zone, or number.
</p><ol type="a" class="substeps"><li class="step"><p> If the numeric token contains a colon (<code class="literal">:</code>), this is
a time string. Include all subsequent digits and colons.
</p></li><li class="step"><p> If the numeric token contains a dash (<code class="literal">-</code>), slash
(<code class="literal">/</code>), or two or more dots (<code class="literal">.</code>), this is
a date string which might have a text month. If a date token has
already been seen, it is instead interpreted as a time zone
name (e.g., <code class="literal">America/New_York</code>).
</p></li><li class="step"><p> If the token is numeric only, then it is either a single field
or an ISO 8601 concatenated date (e.g.,
<code class="literal">19990113</code> for January 13, 1999) or time
(e.g., <code class="literal">141516</code> for 14:15:16).
</p></li><li class="step"><p> If the token starts with a plus (<code class="literal">+</code>) or minus
(<code class="literal">-</code>), then it is either a numeric time zone or a special
field.
</p></li></ol></li><li class="step"><p> If the token is a text string, match up with possible strings:
</p><ol type="a" class="substeps"><li class="step"><p> Do a binary-search table lookup for the token as a time zone
abbreviation.
</p></li><li class="step"><p> If not found, do a similar binary-search table lookup to match
the token as either a special string (e.g., <code class="literal">today</code>),
day (e.g., <code class="literal">Thursday</code>),
month (e.g., <code class="literal">January</code>),
or noise word (e.g., <code class="literal">at</code>, <code class="literal">on</code>).
</p></li><li class="step"><p> If still not found, throw an error.
</p></li></ol></li><li class="step"><p> When the token is a number or number field:
</p><ol type="a" class="substeps"><li class="step"><p> If there are eight or six digits,
and if no other date fields have been previously read, then interpret
as a <span class="quote">“<span class="quote">concatenated date</span>”</span> (e.g.,
<code class="literal">19990118</code> or <code class="literal">990118</code>).
The interpretation is <code class="literal">YYYYMMDD</code> or <code class="literal">YYMMDD</code>.
</p></li><li class="step"><p> If the token is three digits
and a year has already been read, then interpret as day of year.
</p></li><li class="step"><p> If four or six digits and a year has already been read, then
interpret as a time (<code class="literal">HHMM</code> or <code class="literal">HHMMSS</code>).
</p></li><li class="step"><p> If three or more digits and no date fields have yet been found,
interpret as a year (this forces yy-mm-dd ordering of the remaining
date fields).
</p></li><li class="step"><p> Otherwise the date field ordering is assumed to follow the
<code class="varname">DateStyle</code> setting: mm-dd-yy, dd-mm-yy, or yy-mm-dd.
Throw an error if a month or day field is found to be out of range.
</p></li></ol></li><li class="step"><p> If BC has been specified, negate the year and add one for
internal storage. (There is no year zero in the Gregorian
calendar, so numerically 1 BC becomes year zero.)
</p></li><li class="step"><p> If BC was not specified, and if the year field was two digits in length,
then adjust the year to four digits. If the field is less than 70, then
add 2000, otherwise add 1900.
</p><div class="tip"><h3 class="title">Tip</h3><p> Gregorian years AD 1-99 can be entered by using 4 digits with leading
zeros (e.g., <code class="literal">0099</code> is AD 99).
</p></div><p>
</p></li></ol></div></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="datetime-appendix.html">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="datetime-appendix.html">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="datetime-keywords.html">Next</a></td></tr><tr><td width="40%" align="left" valign="top">Appendix B. Date/Time Support </td><td width="20%" align="center"><a accesskey="h" href="index.html">Home</a></td><td width="40%" align="right" valign="top"> B.2. Date/Time Key Words</td></tr></table></div></body></html>