Re: Storing Times in Oracle

From: Hans Forbrich <forbrich_at_tibalt.supernet.ab.ca>
Date: 1996/10/01
Message-ID: <3251F2C3.693E_at_tibalt.supernet.ab.ca>#1/1


Alan Clement wrote:
>
> I have a need to store times (eg elapsed times etc) in an Oracle7
> database. As you may know there is no native TIME datatype in Oracle,
> and the DATE datatype seems inadequate as it requires a date and time.
>
> Does anyone have any suggestions, or has overcome this before ?
>
> Cheers Alan
> --

Two of the ways I have used:

  1. Elapsed time (say in seconds) - store as a number. This can be then translated to hour:min:sec as needed through code.
  2. Actual time - store as a datetime, and either ignore the date [to_date('12:34:56', 'HH:MI:SS')], keep the date, esp. if you plan on working around midnight, or set the date explicitly.

Just because it's called 'date' type doesn't mean it can't do the job. Personally, I've found it more powerful and ultimately easier than trying to keep 'date', 'time' and 'datetime' separate.

However, that's just MHO
/Hans Received on Tue Oct 01 1996 - 00:00:00 CEST

Original text of this message