HyperCard: Calculating Interval Between Two Dates (7/92)

Here's a handler that calculate the number of days, hours, and
minutes between any two dates.

1) Create five fields, one for the first date, one for the second date,
and the other three for days, hours and minutes.

2) Use the following handler:

on mouseUp
global numdays,numhours,numminutes,temp
put "" into cd fld 3
put "" into cd fld 4
put "" into cd fld 5
put cd fld 1 into firstdate
put cd fld 2 into seconddate
convert firstdate to seconds
convert seconddate to seconds
put seconddate - firstdate into temp
--how many days worth of seconds
put 24 * 60 * 60 into secdays
put temp div secdays into numdays
put numdays & "days" into cd fld 3
--check for hours
put temp-secdays*numdays into temp
if temp = 0 then put "0 hours" into cd fld 4
if tem >0 then
put 60*60 into sechours
put temp div sechours into numhours
put numhours & "hours" into cd fld 4
--check for minutes
put temp-sechours*numhours into temp
end if
if temp=0 then put "0 minutes" into cd fld 5
if temp > 0 then
put 60 into secminutes
put temp div secminutes into numminutes
put numminutes & " minutes" into cd fld 5
end if
end mouseUp

This article is adapted from the Claris Tech Info database.
Published Date: Feb 19, 2012