Amount of time between 2 dates

hbrems

has no clue...
Local time
Today, 19:08
Joined
Nov 2, 2006
Messages
181
Dear all,

in my table I have the following fields:

- fldstartdate
- fldstarttime

- fldenddate
- fldendtime

Can I calculate the time that is between those variables using an expression?

fldenddate.fldendtime - fldstartdate.fldstarttime = "x days and x minutes"

Kind regards,
Hans B.
 

Attachments

  • date.JPG
    date.JPG
    17.7 KB · Views: 114
Last edited:
Are you aware of the fact that Now() stores both Date *and* Time and saves disk space and cpu cycles.

No, I wasn't. That's a very useful remark. I guess it will also make my calculations easier with 2 fields (fldstart & fldend) instead of splitting them up.
 
Can I calculate the time that is between those variables using an expression?

fldenddate.fldendtime - fldstartdate.fldstarttime = "x days and x minutes"

Since date/time fields are internally numbers, you can calculate the elapsed time like this:
(fldenddate+fldendtime) - (fldstartdate+fldstarttime)

The integer of the above expression is the number of days and you can use the Format() function to extract the hours, minutes and seconds from the expression.

See the query in the attached database.
.
 

Attachments

Thanks Jon. That was the initial solution that I was looking for! :)
 

Users who are viewing this thread

Back
Top Bottom