Search Postgresql Archives

Re: Constructors for dates, times, and timestamps

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Andrew T. Robinson" <atr@xxxxxxx> 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


[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
[Index of Archives]     [Postgresql Jobs]     [Postgresql Admin]     [Postgresql Performance]     [Linux Clusters]     [PHP Home]     [PHP on Windows]     [Kernel Newbies]     [PHP Classes]     [PHP Books]     [PHP Databases]     [Postgresql & PHP]     [Yosemite]
  Powered by Linux