Re: rounding interval type to nearest 15 minute
Posted in 1996
Topics: Stored Procedures & SPL
Not easy but variable i1,i3 interval day to minute variable i2 interval minute(5) to minute variable p1,p2,p3 decimal (10,2) variable j1 integer variable s1 char(15) let i1 = "2 12:8" display "I got i1=" ,i1 let i2 = i1 display "I got mins=" ,i2 let s1=i2 display "I got string = ",s1 let p1 = s1 display "I got mins=" ,p1 let p2=p1/15 display "I got 15 mins =" ,p2 let p3=p2+.5 display "I got rounded 15 mins=",p3 let j1=p3 display "I got int=",j1 let i3=(j1*15) units minute display "I got intrval=",i3 If you want to consider seconds then you just extend i1 to seconds, make i2 seconds(5) to seconds, divide by 15*60 etc. Having to go to the string is really grubby - it should be possible to go directly from an interval to a number by specifying the units eg d=i1 units second In article <326E4676.62AD@amgen.com>, Douglas Wilson <dougw@amgen.com> writes: > Marc Kneppers wrote: > > > ANyone have an easy way of rounding an interval up or down to the > > nearest 15 minute interval? > I don't think so. > > am I missing something obvious? > Convert the interval to a string, parse the string to grab the > minutes and convert to an integer so you can round that to whatever > you want, then put the modify or reconstruct the string and convert > back to an interval. > Or am I missing something obvious? > > > MArc > > > > -------------------------------------------------------------------------- > > Marc Kneppers > > System Administrator and Everything-Under-the-Sun-guy > > PAMCO > > marc@pamco.com > > -------------------------------------------------------------------------- > > "Kiss my Royal Canadian" > > -- > Sincerly, > Doug Wilson(dougw@amgen.com) > *** The opinions expressed here are my own and not neccessarily *** > *** anyone elses **** > *** Disclaimer: These are the opinions of the poster not Amgen Inc.*** -- ---------------------------------------------------------------------- David Paulo, InForm Group Ltd.,PO Box 1444, Wellington, New Zealand. Ph: +64 4 472 0996 Fax: +64 4 473 2407 Email: david@inform.co.nz = What would you do if you knew that you could not fail = ----------------------------------------------------------------------