[Date Prev][Date Next][Thread Prev][Thread Next]
[Author Index]
[Date Index]
[Thread Index]
[SQR-USERS Info]
[SQRUG Home Page]
Re: Date-time math
- Subject: Re: Date-time math
- From: "C. Willis III" <ceprn@HOTMAIL.COM>
- Date: Tue, 20 Oct 1998 11:11:44 CDT
Steve,
Here's one I wrote and use in all my programs that I build from scratch.
I use it as one of my tools when I am working on improving an sqr's
performance. You need to pass in $start_time and $end_time in the
format hh:mi:ss. You can determine the start and end times by using and
formatting date-time or a select (from dual on Oracle) of the database
timestamp.
hope this helps,
clark
!
*******-************************&*********(**,****)****************-**********
! - FIGURE THE TIME DIFF -
!
! - this procedure determines the elapsed time of -
!
! - the processing. [CW] -
!
! - desc : -
!
! - procedure number : 7 -
!
! - called from : 0 -
!
! - 18-May-1998 [CW] -
!
!
*******-************************&*********(**,****)****************-**********
begin-procedure figure_the_time_diff
#debug show ' Now in FIGURE THE TIME DIFF'
let $diff_seconds = ''
let $diff_minutes = ''
let $diff_hours = ''
let #begin_hours = substr($start_time, 1, 2)
let #begin_minutes = substr($start_time, 4, 2)
let #begin_seconds = substr($start_time, 7, 2)
let #finish_hours = substr($end_time, 1, 2)
let #finish_minutes = substr($end_time, 4, 2)
let #finish_seconds = substr($end_time, 7, 2)
if #begin_seconds > #finish_seconds
let #finish_seconds = #finish_seconds + 60
if not #finish_minutes > 0
let #finish_minutes = 60
let #finish_hours = #finish_hours -1
end-if
let #finish_minutes = #finish_minutes -1
end-if
if #finish_minutes = 0 and #start_minutes != 0
let #finish_minutes = 0
let #finish_hours = #finish_hours -1
end-if
if #begin_minutes > #finish_minutes
let #finish_minutes = #finish_minutes + 60
let #finish_hours = #finish_hours -1
end-if
let $diff_seconds = edit(#finish_seconds - #begin_seconds, '09')
let $diff_minutes = edit(#finish_minutes - #begin_minutes, '09')
let $diff_hours = edit(#finish_hours - #begin_hours , '09')
let $run_time = $diff_hours||':'||$diff_minutes||':'||$diff_seconds
end-procedure
----Original Message Follows----
Hi All,
Can anyone point me to an sqc that calculates differences (including
hours
and minutes) between two date-time fields?
Thanks,
Steve
______________________________________________________
Get Your Private, Free Email at http://www.hotmail.com