Determine hours using date and time fields

939 views Asked by At

I have separate date and time fields for an event and the data entry of that event. How do I determine the hours between the event and the data entry?

The time field is a string in standard time which I converted to a military time time field using a formula.

date is written in mm/dd/yyyy format and time is in standard time hh:mm am/pm which I've converted to HH:MM military time.

If an event happened at 12:10 pm on 12/3/2016 but it was entered at 1:25 pm on 12/5/2016, I want to see 49 Hours and 15 Minutes in my final field

1

There are 1 answers

9
4444 On

DateDiff is just what you need. Something like:

DateDiff("h", DateTime({StartDate},{StartTime}), DateTime({EndDate},{EndTime}))
  & " Hours and " &
DateDiff("n", DateTime({StartDate},{StartTime}), DateTime({EndDate},{EndTime})) Mod 60
  & " Minutes"

This will retrieve the difference between your two dateTimes twice - Once in hours, once in minutes. Perform Mod 60 on the minutes section to get only the remainder minutes after subtracting 60 minutes for each hour.