Time Conversion

Поиск
Список
Период
Сортировка
Искать

Time Conversion

От:
"Ryan Sommers" <ryans@gamersimpact.com>
Дата:
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.


-- 
Ryan Sommers
ryans@gamersimpact.com

Re: Time Conversion

От:
Tom Lane <tgl@sss.pgh.pa.us>
Дата:
"Ryan Sommers"  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
FAQ