antiskeptic
Programmer
I have some really strange date fields in my current database. It is a number, counting the minutes since 1/1/1930. So my code to extract the date and time is as follows:
substring(convert( varchar, dateadd( mi, process_raw.start_time,
convert( datetime, '01/01/1930' ) ), 100 ), 13,6) as[starttime],
substring(convert( varchar, dateadd( mi, process_raw.stop_time,
convert( datetime, '01/01/1930' ) ), 100 ), 13,6) as[stoptime]
Then I have a formula that calculates the time between the two:
round((process_raw.stop_time-process_raw.start_time)/60.0,2)[ActualTimeHours]
But I want this [ActualTimeHours] to be rounded to the nearest 15 minutes. So I can use it in the next step of this craziness. (-:
Briefly... the next step entails getting the difference between an extra 2 hours ([Remainder]) and the [ActualTimeHours].
Example:
if [ActualTimeHours] = 1.25 then [Remainder] = .75
or
if [ActualTimeHours] = 1.0 then [Remainder] = 1.0
etc...
If I haven't confused you quite thouroughly, please help point me in the right direction. I've been pondering this problem for a couple days and keep coming up empty. And help would be greatly appreciated!!
Thank you,
AntiSkeptic
substring(convert( varchar, dateadd( mi, process_raw.start_time,
convert( datetime, '01/01/1930' ) ), 100 ), 13,6) as[starttime],
substring(convert( varchar, dateadd( mi, process_raw.stop_time,
convert( datetime, '01/01/1930' ) ), 100 ), 13,6) as[stoptime]
Then I have a formula that calculates the time between the two:
round((process_raw.stop_time-process_raw.start_time)/60.0,2)[ActualTimeHours]
But I want this [ActualTimeHours] to be rounded to the nearest 15 minutes. So I can use it in the next step of this craziness. (-:
Briefly... the next step entails getting the difference between an extra 2 hours ([Remainder]) and the [ActualTimeHours].
Example:
if [ActualTimeHours] = 1.25 then [Remainder] = .75
or
if [ActualTimeHours] = 1.0 then [Remainder] = 1.0
etc...
If I haven't confused you quite thouroughly, please help point me in the right direction. I've been pondering this problem for a couple days and keep coming up empty. And help would be greatly appreciated!!
Thank you,
AntiSkeptic