Calculating Minutes

When calculating minutes; i.e. the difference between two times. For example if you have created Date/Time fields with medium time format. Then you entered 10:00 AM and 12:10 PM, how would you write code that calculates this interval in minutes. To do this you would use the DateDiff function.

If you were to use this in VBA code; an example may look like the following:

Public Sub sTimeInMinutes(Later As Date, NowTime As Date)

Dim TimeIntervalInMinutes As Long

TimeIntervalInMinutes = (DateDiff("n", Later, NowTime))

MsgBox TimeIntervalInMinutes

End Sub

If you wished to work out calculating minutes in a query then using a blank column, in the first row you would type the following:

TimeIntervalInMinutes: (DateDiff("n",[StartTime],[EndTime]))

Where StartTime and EndTime are the names of the fields that contains this information.

Or you may wish to do it on a form or a report. In this case you would add an unbound text box with the following syntax:

= (DateDiff("n",[StartTime],[EndTime]))