Re: Sql time query
Posted in 1996
Topics: Stored Procedures & SPL, Connectivity: ESQL/C, 4GL & Embedded SQL, Data Types & Schema Design
Katelis, Bill wrote: > > Platform: Sun sparc 20, sunos 5.3 > Engine: 5.04.uc2 > isql: 411.uc1 > > Problem: Trying to add duration columns and convert to seconds using sql. > Duration Event > 01:05:56 1 > 01:00:23 1 > 00:12:34 1 > > I can add the duration column using 4gl (converting to char, splitting > values etc) but I am trying to increase the speed of my application. > I have tried to do the following: > select extend(duration,hour to hour)*3600, > extend(duration, minute to minute)*60, > extend(duration, second to second) > from table > where event = 1 > but it connot convert between the data types. I guess my question is, Is > there a way to convert the data type resulting from an extend call to an > integer, > OR, is there another way of doing it? > > Much Appreciated > Bill Katelis > bkatelis@vibupls1.telecom.com.au Hi Bill ! If I understand your problem right then the following SQL should solve your problem: SELECT duration[1,2] * 3600 + duration[4,5] * 60 + duration[7,8] duration_in_secs FROM table WHERE event = 1 Hope this helps ! Cheers, Dirk --------------------------------------------------- Dirk Schmidtpott S I E M E N S EMail: schmd@dbm212.pdb.sni.de ============= Phone: 0049-5251-8-14922 N I X D O R F Fax : 0049-5251-8-27905 The above statements and opinions are my own and do not necessarily represent those of my employer. ---------------------------------------------------