Calculate number of minutes between 2 timestamps (crossover midnight)
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | *(Q) Calculate number of minutes between 2 time stamps where second time is passed midnight. *(A) Posted to SPSSX-L list by Raynald Levesque 2003/01/29. * This assumes that the difference between the 2 time stamps does not exceed 24 hours. DATA LIST LIST /ID SCHEDULE ACTUAL. BEGIN DATA. 1 0630 0630 2 1000 1001 3 1159 1201 4 1350 1353 5 2359 0003 END DATA. COMPUTE time1=TIME.HMS(TRUNC(schedule/100),MOD(schedule,100)). COMPUTE time2=TIME.HMS(TRUNC(actual/100),MOD(actual,100)). IF time2<time1 time2=time2 + TIME.DAYS(1). COMPUTE delta=time2-time1. FORMATS time1 time2 delta (TIME10). |
Related pages
...