Re: Time Conversion - Mailing list pgsql-novice

From Tom Lane
Subject Re: Time Conversion
Date
Msg-id 5631.1111939563@sss.pgh.pa.us
Whole thread Raw
In response to Time Conversion  ("Ryan Sommers" <ryans@gamersimpact.com>)
List pgsql-novice
"Ryan Sommers" <ryans@gamersimpact.com> writes:
> How can I convert a VARCHAR(25) to a timestamp? Including a fraction of a
> second.

> The VARCHAR(25) column is in the form: YYYY-MM-DD HH:MI:SS.fffff
> where fffff is the fraction of a second.

> I could use to_timestamp but I can't find a conversion specifier for the
> fractional part.

Since that's a perfectly valid input format for timestamp, you could
just cast it.

regression=# select '2005-05-27 11:22:33.4567'::varchar::timestamp;
        timestamp
--------------------------
 2005-05-27 11:22:33.4567
(1 row)

            regards, tom lane

pgsql-novice by date:

Previous
From: Bruno Wolff III
Date:
Subject: Re: I'd Like To See Permissions Granted
Next
From: Bruno Wolff III
Date:
Subject: Re: [pgsql-advocacy] Function which gives back the nearest neighbours