Calculate difference in date and time

D

D Johnson

Hello. I am running Access97.

I need to calculate the number of days and hours, or just total hours
between two date fields and two time fields. Example: How many days and
hours (or total hours) from 07/01/2003 08:30:25 AM to 07/04/2003 02:30:12
PM? [Beginningdate] [Endingdate] currently formatted as mm/dd/yyyy and
[Beginningtime][Endingtime] currently formatted as hh:mm:ss AM/PM.

Is there a way to convert and combine the date and time to create numbers
that can be manipulated mathematically? I cannot change the field formats
of the underlying table, but can do what I want in the query and report.

Thank you for your time and knowledge.
 
D

D Johnson

Thank you very much.

--
D. Johnson

John Spencer (MVP) said:
DateDiff("n",[BeginningDate]+[BeginningTime],[EndingDate]+[EndingTime]) \ 60

That should give you the whole hours between the two datetimes. If you want
Hours and Fractions of hours reverse the slash (from \ to /). The above assumes that:
There is always a value in each date and each time
The dates don't have any times associated with them other than midnight
The times don't have any dates associated with them other than the zero date.


D said:
Hello. I am running Access97.

I need to calculate the number of days and hours, or just total hours
between two date fields and two time fields. Example: How many days and
hours (or total hours) from 07/01/2003 08:30:25 AM to 07/04/2003 02:30:12
PM? [Beginningdate] [Endingdate] currently formatted as mm/dd/yyyy and
[Beginningtime][Endingtime] currently formatted as hh:mm:ss AM/PM.

Is there a way to convert and combine the date and time to create numbers
that can be manipulated mathematically? I cannot change the field formats
of the underlying table, but can do what I want in the query and report.

Thank you for your time and knowledge.
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Top