pg.ddx.io  pgsql-general@postgresql.org mailing list archive  
help / color / mirror / Atom feed
to_timestamp function
3+ messages / 3 participants
[nested] [flat]

* to_timestamp function
@ 2003-06-23 09:12  Jaka Erjavec <jaka.erjavec@voljatel.si>
  0 siblings, 0 replies; 3+ messages in thread

From: Jaka Erjavec @ 2003-06-23 09:12 UTC (permalink / raw)
  To: pgsql-general

Hello,

I managed to establish postgresql support for accounting  in Freeradius. It is 
logging all of the radius attributes (including Cisco h323) in the database, 
but the problem is that all this h323 Cisco attributes are set to type 
string. 
I found this postgresql function called to_timestamp(), which should be able 
to convert string in to date. The problem is that Cisco's time format 
(13:17:22.670 CET Fri Jun 20 2003) somehow does not get completely recognized 
when using the function in the following way:

radius=# select to_timestamp('13:17:22.670 CET Fri Jun 20 2003','HH24:MI TZ 
Day Mon DD YYYY');
ERROR:  to_timestamp(): TZ/tz not supported.


So, the question is, what am I doing wrong or is there some bug in this 
function.

postgresql version:
radius=# select version();
                               version
---------------------------------------------------------------------
 PostgreSQL 7.2.4 on i386-portbld-freebsd4.8, compiled by GCC 2.95.4
(1 row)


Thank you!

Jaka



^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* to_timestamp function
@ 2019-03-20 16:12  Gustavsson Mikael <mikael.gustavsson@smhi.se>
  0 siblings, 1 reply; 3+ messages in thread

From: Gustavsson Mikael @ 2019-03-20 16:12 UTC (permalink / raw)
  To: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Hi,

We recently upgraded from PG9.6 to PG11 and I have some questions regarding the function to_timestamp.

We have an application that for some reason unknown to me uses timestamps with hour = 24.
After upgrade we got som problems with this. The solution is to use cast instead of the function but im curious if this is intentional.

Examles:

In PG9.6 this works:

to_timestamp('2019-03-20 24:00','YYYY-MM-DD HH24:MI')

but in PG11 we get:

ERROR:  date/time field value out of range.

I assume this have something to do with this row in releasenotes for PG10:

Make to_timestamp()<https://www.postgresql.org/docs/10/functions-formatting.html#FUNCTIONS-FORMATTING-TABLE; and to_date() reject out-of-range input fields (Artur Zakirov)

  *   For example, previously to_date('2009-06-40','YYYY-MM-DD') was accepted and returned 2009-07-10. It will now generate an error.

But.

This works in both PG9.6 and PG11:

'2019-03-20 24:00'::timestamp with time zone

and this generates an error in both PG9.6 and PG11:

'2009-06-40'::timestamp with time zone

So my question is, is it intentional that to_timestamp is stricter than cast to timestamp?

kr

Mikael Gustavsson
SMHI / Swedish Meteorological and Hydrological Institute

^ permalink  raw  reply  [nested|flat] 3+ messages in thread

* Re: to_timestamp function
@ 2019-03-20 16:33  Tom Lane <tgl@sss.pgh.pa.us>
  parent: Gustavsson Mikael <mikael.gustavsson@smhi.se>
  0 siblings, 0 replies; 3+ messages in thread

From: Tom Lane @ 2019-03-20 16:33 UTC (permalink / raw)
  To: Gustavsson Mikael <mikael.gustavsson@smhi.se>; +Cc: pgsql-general@lists.postgresql.org <pgsql-general@lists.postgresql.org>

Gustavsson Mikael <mikael.gustavsson@smhi.se> writes:
> So my question is, is it intentional that to_timestamp is stricter than cast to timestamp?

Yes.  The point of using that function at all is to be strict about the
input format, so being strict about the field values seems to make
sense along with that.  An independent argument for it is mentioned in
the commit message (d3cd36a13):
    
    Historically, something like to_date('2009-06-40','YYYY-MM-DD') would
    return '2009-07-10' because there was no prohibition on out-of-range
    month or day numbers.  This has been widely panned, and it also turns
    out that Oracle throws an error in such cases.  Since these functions
    are nominally Oracle-compatibility features, let's change that.

			regards, tom lane




^ permalink  raw  reply  [nested|flat] 3+ messages in thread


end of thread, other threads:[~2019-03-20 16:33 UTC | newest]

Thread overview: 3+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-06-23 09:12 to_timestamp function Jaka Erjavec <jaka.erjavec@voljatel.si>
2019-03-20 16:12 to_timestamp function Gustavsson Mikael <mikael.gustavsson@smhi.se>
2019-03-20 16:33 ` Tom Lane <tgl@sss.pgh.pa.us>

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