Thread: TIME vs. TIMESTAMP data type

TIME vs. TIMESTAMP data type

From
Ludwig Lim
Date:
Hi:
   Are there cases when a TIME data type is a better
choice over the TIMESTAMP data type? 
   It seems that PostgreSQL (I'm using 7.2.3)
encourage its users to use TIMESTAMP over TIME data
type. I said this because of the following:  a) More functions for DATE and TIMESTAMP data types
such as to_date() and to_timestamp(). Howver, function
to_time() does not exist.  b) Same amount of storage for TIMESTAMP and for
TIME. Time with time zone even need more storage space
than a timestamp (12 bytes vs. 8 bytes).  c) It's harder to TIMESTAMP to TIME and vice versa,
while its easier to cast TIMESTAMP to DATE and vice
versa.


thank you very much,

ludwig

__________________________________________________
Do you Yahoo!?
Yahoo! Mail Plus - Powerful. Affordable. Sign up now.
http://mailplus.yahoo.com


Re: TIME vs. TIMESTAMP data type

From
Tomasz Myrta
Date:
Ludwig Lim wrote:
> Hi:
> 
>     Are there cases when a TIME data type is a better
> choice over the TIMESTAMP data type? 
> 
>     It seems that PostgreSQL (I'm using 7.2.3)
> encourage its users to use TIMESTAMP over TIME data
> type. I said this because of the following:
>    a) More functions for DATE and TIMESTAMP data types
> such as to_date() and to_timestamp(). Howver, function
> to_time() does not exist.
>    b) Same amount of storage for TIMESTAMP and for
> TIME. Time with time zone even need more storage space
> than a timestamp (12 bytes vs. 8 bytes).
>    c) It's harder to TIMESTAMP to TIME and vice versa,
> while its easier to cast TIMESTAMP to DATE and vice
> versa.
> 
> 
> thank you very much,
> 
> ludwig


Probably you are right, but you can cast into timestamp before using these functions.
Do you really need to care amount of storage?
Don't forget about INTERVAL type, which is very useful for time calculations.

Regards,
Tomasz Myrta





Re: TIME vs. TIMESTAMP data type

From
Ludwig Lim
Date:
Hi Tomasz:

--- Tomasz Myrta <jasiek@klaster.net> wrote:
> 
> Probably you are right, but you can cast into
> timestamp before using these functions.
> Do you really need to care amount of storage?
 I was just thinking if both TIMESTAMP and TIME have
use the same amount of space (I was think TIME might
use less space since it doesn't need to store month,
year, day as compared to TIMESTAMP), and TIMESTAMP
have more functions and is easier to cast, I might as
well use TIMESTAMP.

> Don't forget about INTERVAL type, which is very
> useful for time calculations.
> --> I'll check that one out. 


__________________________________________________
Do you Yahoo!?
New DSL Internet Access from SBC & Yahoo!
http://sbc.yahoo.com


Re: TIME vs. TIMESTAMP data type

From
Julian Scarfe
Date:
On 6/2/03 11:04, "Ludwig Lim" <lud_nowhere_man@yahoo.com> wrote:

>   Are there cases when a TIME data type is a better
> choice over the TIMESTAMP data type?

Surely this depends on the nature of the data that you want to represent?

If you're researching into sleep patterns and want to represent the times
each day that subjects say they tend to wake and/or fall asleep, you may
want the TIME type, as the important aspect is the time, not the date.  The
inclusion of a date would be nonsensical.

If you want to record *when* an event occurred, you usually want date and
time, so TIMESTAMP is more appropriate.

Since event timing is a much more frequent requirement than a time-of-day,
it's not surprising that the facilities may be better developed for dealing
with that type.

Julian Scarfe