pg.ddx.io  pgsql-bugs@postgresql.org mailing list archive  
help / color / mirror / Atom feed
From: Tom Lane <tgl@sss.pgh.pa.us>
To: Andreas Rhode <Andreas.Rhode@gmx.de>
Cc: pgsql-bugs@postgresql.org, "Rhode,A.,SNL IT BRIEF,2520,DA, Berater" <andreas.rhode@deutschepost.de>
Subject: Re: to_date() not works as described for pattern DD & HH
Date: Fri, 18 Dec 2015 10:43:42 -0500
Message-ID: <6847.1450453422@sss.pgh.pa.us> (raw)
In-Reply-To: <4C903B6A-2FE0-4164-9633-50581F1B58CA@gmx.de>
References: <4C903B6A-2FE0-4164-9633-50581F1B58CA@gmx.de>
List-Unsubscribe: <mailto:majordomo@postgresql.org?body=unsub%20pgsql-bugs>

Andreas Rhode <Andreas.Rhode@gmx.de> writes:
> The 2 Pattern DD/HH are not well working
> All Digs ar counted from Position6/8  are counted as Days or Hour
> and produce a future Date or error from a Timestamp in Milliseconds

As far as I can see, the problem here is that you're not giving a pattern
that accurately describes the input data.

> SELECT to_date('20151202115909001','YYYYMMDD') AS der_2_december_eleven_a_clock
> -> "5795177-12-29“ 	=> fare away in the future

A correct format for this input would be something like YYYYMMDDHH24MISSMS:

# SELECT to_timestamp('20151202115909001','YYYYMMDDHH24MISSMS');
        to_timestamp        
----------------------------
 2015-12-02 11:59:09.001-05
(1 row)

I think what is happening in your example is that it's including all the
remaining adjacent digits in the DD field.  While this seems silly here,
it's less silly in, for example,

# SELECT to_date('201512021','YYYYMMDD');
  to_date   
------------
 2015-12-21
(1 row)

But it's not really to_date's job to parse input that is not correctly
described by the given format.

			regards, tom lane


-- 
Sent via pgsql-bugs mailing list (pgsql-bugs@postgresql.org)
To make changes to your subscription:
http://www.postgresql.org/mailpref/pgsql-bugs



view thread (2+ messages)

Message-ID: <6847.1450453422@sss.pgh.pa.us>
Permalink:  ../6847.1450453422@sss.pgh.pa.us/
Also on:    postgresql.org/message-id/6847.1450453422@sss.pgh.pa.us

 · 

reply

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Reply to all the recipients from your mail client; the link fills in
  the headers below: reply via email
  Some clients, webmail especially, drop In-Reply-To and References from
  a link, and the reply then starts a new thread: use the mbox below.

  To: pgsql-bugs@postgresql.org
  Cc: tgl@sss.pgh.pa.us, Andreas.Rhode@gmx.de, andreas.rhode@deutschepost.de
  Subject: Re: to_date() not works as described for pattern DD & HH
  In-Reply-To: <6847.1450453422@sss.pgh.pa.us>
  References: <4C903B6A-2FE0-4164-9633-50581F1B58CA@gmx.de> <6847.1450453422@sss.pgh.pa.us>

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox