General discussion

Locked

Calculating time in Access 2000

By Ray Gross ·
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?

This conversation is currently closed to new comments.

7 total posts (Page 1 of 1)  
| Thread display: Collapse - | Expand +

All Comments

Collapse -

Calculating time in Access 2000

by DKlippert In reply to Calculating time in Acces ...

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.

Collapse -

Calculating time in Access 2000

by Ray Gross In reply to Calculating time in Acces ...

The question was auto-closed by TechRepublic

Collapse -

Calculating time in Access 2000

by sandymac In reply to Calculating time in Acces ...

also a formula can help...
=format(([ET]-[ST]), "HH:MM")
Look up Format for options inside ""

Collapse -

Calculating time in Access 2000

by Ray Gross In reply to Calculating time in Acces ...

The question was auto-closed by TechRepublic

Collapse -

Calculating time in Access 2000

by RichTee In reply to Calculating time in Acces ...

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

Collapse -

Calculating time in Access 2000

by Ray Gross In reply to Calculating time in Acces ...

The question was auto-closed by TechRepublic

Collapse -

Calculating time in Access 2000

by Ray Gross In reply to Calculating time in Acces ...

This question was auto closed due to inactivity

Back to Web Development Forum
7 total posts (Page 1 of 1)  

Related Discussions

Related Forums