Time question

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

I have a field in a form, called "travel time" that is calculating the
difference between 2 other fields: "start time" and "end time". I am using
the date diff function as : datediff("n", [start time], [end time])
The result is a whole number. I would like to display the result as: h:mm
How can this be done?
Thank you,
 
You'll need to "parse" your total number of minutes into hours and minutes.

Divide by 60 to get hours, add a ":", then take the remainder (you can use
the MOD function) to get minutes.

Regards

Jeff Boyce
Microsoft Office/Access MVP
 
How would I add that, and how would the formula be written?

Jeff Boyce said:
You'll need to "parse" your total number of minutes into hours and minutes.

Divide by 60 to get hours, add a ":", then take the remainder (you can use
the MOD function) to get minutes.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Iago said:
I have a field in a form, called "travel time" that is calculating the
difference between 2 other fields: "start time" and "end time". I am using
the date diff function as : datediff("n", [start time], [end time])
The result is a whole number. I would like to display the result as: h:mm
How can this be done?
Thank you,
 
x= DateDiff("n", StartTime, EndTime)
Me.txtTravelTime = format(x\60,"00:") & format(x mod 60, "00")

Notice the \ as the operator. It returns only the integer of the division
which is what you want in this case.

--
Dave Hargis, Microsoft Access MVP


Iago said:
How would I add that, and how would the formula be written?

Jeff Boyce said:
You'll need to "parse" your total number of minutes into hours and minutes.

Divide by 60 to get hours, add a ":", then take the remainder (you can use
the MOD function) to get minutes.

Regards

Jeff Boyce
Microsoft Office/Access MVP

Iago said:
I have a field in a form, called "travel time" that is calculating the
difference between 2 other fields: "start time" and "end time". I am using
the date diff function as : datediff("n", [start time], [end time])
The result is a whole number. I would like to display the result as: h:mm
How can this be done?
Thank you,
 
Back
Top