Skip to content
ptrb edited this page Jun 9, 2013 · 3 revisions

Supported Casts

The PostTIME extension supports casts to and from

  • date,
  • timestamp with time zone, and
  • timestamp without time zone.

A cast from a timestamp will produce an instant in any case and you can only cast into timestamps with instants. A cast to timestamp with time zone will convert the PostTIME instance into your time zone, according to the PostgreSQL settings. On the contrary casts into date are also possible with periods, on the condition that the period's start and end instants have to belong to the same day. If you cast date to PostTIME you get a period, representing the whole day.

Examples

SELECT (('2013-5-11')::date)::posttime;
-- result
'CAL0012013-05-11T00:00:00.000Z/2013-05-12T00:00:00.000Z'

SELECT (('2013-5-11T12')::posttime)::timestamp without time zone;
-- result
'Sat May 11 12:00:00 2013'

SELECT (('2013-5-11T12')::posttime)::timestamp with time zone;
-- result
'Sat May 11 05:00:00 2013 PDT'