From: | Tom Lane <tgl(at)sss(dot)pgh(dot)pa(dot)us> |
---|---|
To: | "Andrew T(dot) Robinson" <atr(at)nmi(dot)net> |
Cc: | pgsql-general(at)postgresql(dot)org |
Subject: | Re: Constructors for dates, times, and timestamps |
Date: | 2007-03-01 16:38:05 |
Message-ID: | 25227.1172767085@sss.pgh.pa.us |
Views: | Raw Message | Whole Thread | Download mbox | Resend email |
Thread: | |
Lists: | pgsql-general |
"Andrew T. Robinson" <atr(at)nmi(dot)net> writes:
> The following work under DB/2, but I can find no analog in the
> PostgreSQL documentation:
> time('00:00:00') [there is to_date() and to_timestamp(), but no
> to_time()?]
Write it as a cast, either SQL-spec CAST() or PG :: notation.
regression=# select '00:00:00'::time;
time
----------
00:00:00
(1 row)
In many situations PG also accepts the same function-like notation for
specifying casts that DB/2 seems to be using, but in this particular
case it doesn't work because TIME(n) is a datatype specification
according to the SQL spec, and the special syntax needed for that
conflicts with this usage.
> timestamp(u.date, u.time) [where u.date is of type DATE and u.time
> is of type TIME]
You can add a date and a time to get a timestamp:
regression=# select '3-1-2007'::date + '12:34'::time;
?column?
---------------------
2007-03-01 12:34:00
(1 row)
regards, tom lane
From | Date | Subject | |
---|---|---|---|
Next Message | Albe Laurenz | 2007-03-01 16:39:00 | Re: cast bytea to text |
Previous Message | Jan Muszynski | 2007-03-01 16:38:00 | ftell mismatch with expected position |