Thread: Question on timestamp in psql

Question on timestamp in psql

From
Robert Rothe
Date:
When I type the following at the psql prompt:

select timestamp('now');

...I always get december 31, 1999.

If I use 'now' as the rvalue to a SET, or within an INSERT, it returns
the correct date.

Is this a known problem?  I'm running 6.5.2-1.

Thanks,
Rob

Re: [GENERAL] Question on timestamp in psql

From
Bruce Momjian
Date:
> When I type the following at the psql prompt:
>
> select timestamp('now');
>
> ...I always get december 31, 1999.
>
> If I use 'now' as the rvalue to a SET, or within an INSERT, it returns
> the correct date.
>
> Is this a known problem?  I'm running 6.5.2-1.

Yikes, confirmed in current sources:

    test=> select timestamp('now');
           timestamp
    ------------------------
     1999-12-31 19:00:00-05
    (1 row)

This works:

    test=> select timestamp('now'::timestamp);
           timestamp
    ------------------------
     2000-01-11 11:28:08-05
    (1 row)

--
  Bruce Momjian                        |  http://www.op.net/~candle
  maillist@candle.pha.pa.us            |  (610) 853-3000
  +  If your life is a hard drive,     |  830 Blythe Avenue
  +  Christ can be your backup.        |  Drexel Hill, Pennsylvania 19026

Re: [GENERAL] Question on timestamp in psql

From
Ed Loehr
Date:
Robert Rothe wrote:

> When I type the following at the psql prompt:
>
> select timestamp('now');

Try
    select timestamp(now());

Cheers,
Ed Loehr