Re: Newbie timestamp question - Mailing list pgsql-general

From Bruno Wolff III
Subject Re: Newbie timestamp question
Date
Msg-id 20040317191954.GA16639@wolff.to
Whole thread Raw
In response to Newbie timestamp question  ("Robin 'Sparky' Kopetzky" <sparkyk@blackmesa-isp.net>)
List pgsql-general
On Wed, Mar 17, 2004 at 11:52:19 -0700,
  Robin 'Sparky' Kopetzky <sparkyk@blackmesa-isp.net> wrote:
> Good Morning!!
>
>     I'm repairing a series of scripts in PHP that use the 'datetime' of MySQL
> and converting them to Postgres. Question is this: The datetime format used
> in the script is 'YYYYMMDDHHMMSS' as a text string. Do I have to convert
> this to the format shown in the Postgres manual: '1999-01-08 04:05:06' for
> Postgres to accept the value or can I just pass an integer as 19990108040506
> for the timestamp?

You certainly couldn't have it as an integer. Even as type unknown
(which you get by quoting the constant) it doesn't work. You can use
to_timestamp to convert the string. For example:
bruno=> select to_timestamp('19990108040506', 'YYYYMMDDHH24MISS');
      to_timestamp
------------------------
 1999-01-08 04:05:06+00
(1 row)

pgsql-general by date:

Previous
From: Richard Huxton
Date:
Subject: Re: Newbie timestamp question
Next
From: Andrew Sullivan
Date:
Subject: Re: Data Corruption in case of abrupt failure