Oracle FAQ | Your Portal to the Oracle Knowledge Grid |
Home -> Community -> Usenet -> c.d.o.server -> Re: How do i store "TIME DURATION" (what datatype should i use?)
In article <2jtr5.873$wS1.60471_at_nntp2.onemain.com>,
"Barbara Kennedy" <barbken_at_teleport.com> wrote:
> Just store the time as a number of seconds. Then you could have a
view that
> separates the seconds into hours, minutes, seconds columns. Then
sorting on
> elapsed time is easy. You can have 2 functions one that takes hours,
> minutes, seconds and converts it into seconds and one that takes
seconds and
> converts it into a fixed string hh:mi:ss e.g. (01:45:32). > Jim > "Alexandros Kotsiras, NYC" <alexandros_k_at_prodigy.net> wrote in message > news:39ACC42C.318B8EC6_at_prodigy.net... > > Hello, > > I am building a database of Video Tapes. > > Each tape (a record of the TAPE table) should have an attribute that > > describes the "Total Recorded Time" of the tape > > for example 1 Hour 25 minutes and 35 seconds. (This is not thecapacity
> > tape through the interface , for example 3 > > text boxes for Hours, Minutes , Seconds. > > I am wondering what is the best way to store this information. > > > > I was thinking of using 3 NUMBER fields in the Tape table (3Attributes
> > called HOURS , MINUTES, SECONDS) > > Is that approach right ? > > Then i can easily order by HOURS, MINUTES, SECONDS in my sqlstatement.
> > and 59) > > > > I think that the DATE datatype is not appropriate since there is nodate
> > the tapes according to the Total Recorder Time. > > > > I would like to verify that my approach is right or I would like tohear
> > a better one. > > > > Thanks, > > Alex. > > > > > > > >
Here is a sample function to return hours, minutes and seconds from the total seconds:
create or replace function get_hms(ttlsecs in integer) return varchar2 as
--
-- David Fitzjarrell Oracle Certified DBA Sent via Deja.com http://www.deja.com/ Before you buy.Received on Thu Aug 31 2000 - 10:41:51 CDT