[EpiData-list] Calculating elapsed time for a procedure crossing midnight ?

epidata-list at lists.umanitoba.ca epidata-list at lists.umanitoba.ca
Sat Mar 18 09:00:34 CST 2006


If the procedure will never be less than a few hours, this is just a 
matter of checking whether end time is less than start time - code added 
below. For a procedure or event that can take more than 24 hours, you 
have to have a separate field for end date.
---Jamie

Dale wrote:
> I'm a novice epidata user and am calculating elapsed time for a 
> procedure (never more than a few hours) which can cross midnight.  
> This is implicit if the ending time is less than the starttime.  Can 
> anyone suggest how modify the code below to add a day when the endtime 
> is after midnight?  Thanks!  --Dale
>
> BEFORE FILE
>   DEFINE varStartTime ########.#####
>   DEFINE varEndTIME ########.#####
> END
>
> STARTTIM
>   RANGE 0 23.59
> END
>
> ENDTIME
>   RANGE 0 23.59
>   AFTER ENTRY
>     varStartTime=STARTDAT+TIME2NUM(STARTTIM)
>     varEndTime=STARTDAT+TIME2NUM(ENDTIME)
          if endtime < starttim then
             varendtime = varendtime + 1  // add one day to end time
          endif
          HOURSMIN=NUM2TIME(varEndTime-varStartTime)
> END
>
>
> HOURSMIN
>   NOENTER
> END




More information about the EpiData-list mailing list