Re: CURRENT_TIMESTAMP vs actual time - Mailing list pgsql-general

From Thomas Hallgren
Subject Re: CURRENT_TIMESTAMP vs actual time
Date
Msg-id d48g50$fqd$1@sea.gmane.org
Whole thread Raw
In response to Re: CURRENT_TIMESTAMP vs actual time  ("Christopher J. Bottaro" <cjbottaro@alumni.cs.utexas.edu>)
Responses Re: CURRENT_TIMESTAMP vs actual time  (Alban Hertroys <alban@magproductions.nl>)
Re: CURRENT_TIMESTAMP vs actual time  (Scott Marlowe <smarlowe@g2switchworks.com>)
List pgsql-general
Christopher J. Bottaro wrote:
> Alvaro Herrera wrote:
>
>
>>On Thu, Apr 21, 2005 at 09:22:26AM -0500, Christopher J. Bottaro wrote:
>>
>>>John DeSoi wrote:
>>>
>>>
>>>>On Apr 20, 2005, at 6:15 PM, Christopher J. Bottaro wrote:
>>>>
>>>>
>>>>>I understand that CURRENT_TIMESTAMP marks the beginning of the current
>>>>>transaction.  I want it to be the actual time.  How do I do this?
>>>>>timeofday() returns a string, how do I convert that into a TIMESTAMP?
>>>>
>>>>timeofday()::timestamp;
>>>
>>>Great, that did it, thanks.  I also found out that you can say
>>>CAST(timeofday() AS TIMESTAMP).  I assume its the same thing...
>>
>>Not sure it's the same thing.  IIRC, CURRENT_TIMESTAMP returns a
>>timestamp with time zone, whereas casting to timestamp unadorned returns
>>a timestamp without time zone.  Try
>>
>>cast(timeofday() as timestamptz)
>>or
>>cast(timeofday() as timestamp with time zone)
>>
>>It may not matter a lot but you may as well be aware of the difference ...
>
>
> Ahh, thanks for the tip.  I guess I'll just stick with
> timeofday()::timestamp...its more concise anyways...
>

Why use timeofday() at all? Why not now(). It will return a timestamptz
without casts.

Regards,
Thomas Hallgren

pgsql-general by date:

Previous
From: Bill Chandler
Date:
Subject: Finding cardinality of an index
Next
From: Scott Marlowe
Date:
Subject: Re: Filesystem options for storing pg_data