Team Ai
Datasetpublic

codekingpro/portable-devtools

sourceHugging Faceupdated 5mo agoView on Hugging Face
1likes15kdownloads
datetime-invalid-input.html62 linesDownload Raw Back to html
1<?xml version="1.0" encoding="UTF-8" standalone="no"?>2<!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.2. Handling of Invalid or Ambiguous Timestamps</title><link rel="stylesheet" type="text/css" href="stylesheet.css" /><link rev="made" href="pgsql-docs@lists.postgresql.org" /><meta name="generator" content="DocBook XSL Stylesheets Vsnapshot" /><link rel="prev" href="datetime-input-rules.html" title="B.1. Date/Time Input Interpretation" /><link rel="next" href="datetime-keywords.html" title="B.3. Date/Time Key Words" /></head><body id="docContent" class="container-fluid col-10"><div class="navheader"><table width="100%" summary="Navigation header"><tr><th colspan="5" align="center">B.2. Handling of Invalid or Ambiguous Timestamps</th></tr><tr><td width="10%" align="left"><a accesskey="p" href="datetime-input-rules.html" title="B.1. Date/Time Input Interpretation">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 16.3 Documentation">Home</a></td><td width="10%" align="right"> <a accesskey="n" href="datetime-keywords.html" title="B.3. Date/Time Key Words">Next</a></td></tr></table><hr /></div><div class="sect1" id="DATETIME-INVALID-INPUT"><div class="titlepage"><div><div><h2 class="title" style="clear: both">B.2. Handling of Invalid or Ambiguous Timestamps <a href="#DATETIME-INVALID-INPUT" class="id_link">#</a></h2></div></div></div><p>3    Ordinarily, if a date/time string is syntactically valid but contains4    out-of-range field values, an error will be thrown.  For example, input5    specifying the 31st of February will be rejected.6   </p><p>7    During a daylight-savings-time transition, it is possible for a8    seemingly valid timestamp string to represent a nonexistent or ambiguous9    timestamp.  Such cases are not rejected; the ambiguity is resolved by10    determining which UTC offset to apply.  For example, supposing that the11    <a class="xref" href="runtime-config-client.html#GUC-TIMEZONE">TimeZone</a> parameter is set12    to <code class="literal">America/New_York</code>, consider13</p><pre class="programlisting">14=&gt; SELECT '2018-03-11 02:30'::timestamptz;15      timestamptz16------------------------17 2018-03-11 03:30:00-0418(1 row)19</pre><p>20    Because that day was a spring-forward transition date in that time zone,21    there was no civil time instant 2:30AM; clocks jumped forward from 2AM22    EST to 3AM EDT.  <span class="productname">PostgreSQL</span> interprets the23    given time as if it were standard time (UTC-5), which then renders as24    3:30AM EDT (UTC-4).25   </p><p>26    Conversely, consider the behavior during a fall-back transition:27</p><pre class="programlisting">28=&gt; SELECT '2018-11-04 01:30'::timestamptz;29      timestamptz30------------------------31 2018-11-04 01:30:00-0532(1 row)33</pre><p>34    On that date, there were two possible interpretations of 1:30AM; there35    was 1:30AM EDT, and then an hour later after clocks jumped back from36    2AM EDT to 1AM EST, there was 1:30AM EST.37    Again, <span class="productname">PostgreSQL</span> interprets the given time38    as if it were standard time (UTC-5).  We can force the other39    interpretation by specifying daylight-savings time:40</p><pre class="programlisting">41=&gt; SELECT '2018-11-04 01:30 EDT'::timestamptz;42      timestamptz43------------------------44 2018-11-04 01:30:00-0445(1 row)46</pre><p>47   </p><p>48    The precise rule that is applied in such cases is that an invalid49    timestamp that appears to fall within a jump-forward daylight savings50    transition is assigned the UTC offset that prevailed in the time zone51    just before the transition, while an ambiguous timestamp that could fall52    on either side of a jump-back transition is assigned the UTC offset that53    prevailed just after the transition.  In most time zones this is54    equivalent to saying that <span class="quote">“<span class="quote">the standard-time interpretation is55    preferred when in doubt</span>”</span>.56   </p><p>57    In all cases, the UTC offset associated with a timestamp can be58    specified explicitly, using either a numeric UTC offset or a time zone59    abbreviation that corresponds to a fixed UTC offset.  The rule just60    given applies only when it is necessary to infer a UTC offset for a time61    zone in which the offset varies.62   </p></div><div class="navfooter"><hr /><table width="100%" summary="Navigation footer"><tr><td width="40%" align="left"><a accesskey="p" href="datetime-input-rules.html" title="B.1. Date/Time Input Interpretation">Prev</a> </td><td width="20%" align="center"><a accesskey="u" href="datetime-appendix.html" title="Appendix B. Date/Time Support">Up</a></td><td width="40%" align="right"> <a accesskey="n" href="datetime-keywords.html" title="B.3. Date/Time Key Words">Next</a></td></tr><tr><td width="40%" align="left" valign="top">B.1. Date/Time Input Interpretation </td><td width="20%" align="center"><a accesskey="h" href="index.html" title="PostgreSQL 16.3 Documentation">Home</a></td><td width="40%" align="right" valign="top"> B.3. Date/Time Key Words</td></tr></table></div></body></html>