Calculating time in Access 2000
I have 2 time fields: StartTime and EndTime.
I want a third field (TotalTime) to Automatically calculate the value of EndTime minus StartTime and display the result in an HH:MM (short time) format.
How do I do this?
Web Development
I have 2 time fields: StartTime and EndTime.
I want a third field (TotalTime) to Automatically calculate the value of EndTime minus StartTime and display the result in an HH:MM (short time) format.
How do I do this?
by dklippert
Calculations, of course, should be performed outside of data tables. Let's assume that this is in a Query. In an empty column in the Field cell type
Difference: [EndTime]-[StartTime]
Right click the field and choose Properties. Format using ShortTime.
by ray gross
by sandymac
also a formula can help...
=format(([ET]-[ST]), "HH:MM")
Look up Format for options inside ""
by ray gross
by richtee
Another simple solution would be to add code to the ?AfterUpdate? event of the EndTime control.
Assuming the three controls are named: txtStartTime; txtEndTime; and txtTimeDiff, put the following code in the AfterUpdate event for the ?txtEndTime?control:
Private Sub txtEndTime_AfterUpdate()
txtTimeDiff.Value = TxtEndTime.Value - TxtStartTime.Value
End Sub
As soon as the End Time is entered, the difference in time will be calculated in the ?txtTimeDiff? control. Format as ShortTime.
This assumes that the times entered are in the same day. Additional code would be needed if your time span is not in the same day.
Good Luck
Rich
by ray gross
by ray gross
This discussion is closed to new replies.
Sort by Trending