How to calculate the difference between to two date and time field

G

Guest

I have two field in an Access table which I want to cclculate the difference
of two date & time fields in a query. For example:

Calculate the difference of

3/8/2005 2:00:00 PM and 3/7/2005 5:46:44 AM

Thanks in advance.
 
G

Guest

Look in help on the DateDiff function. This will allow you to calculate the
difference between 2 dates and show the results as days, months, years, hours
etc.
DateDiff("d",date1,date2) gives the difference in days.
 
G

Guest

Dennis said:
Look in help on the DateDiff function. This will allow you to calculate the
difference between 2 dates and show the results as days, months, years, hours
etc.
DateDiff("d",date1,date2) gives the difference in days.
 
G

Guest

Dennis said:
Look in help on the DateDiff function. This will allow you to calculate the
difference between 2 dates and show the results as days, months, years, hours
etc.
DateDiff("d",date1,date2) gives the difference in days.

I'm sorry, but I'm a novice user of Access, can you be more specific. I can
calculate the date field but still having problem when the field contains
both the date and time. I would appreciate if you can send me the
expression I would use within a query.... DateDiff expression.

Thanks once again.
 
G

Guest

In the field row of a column in your query type in the line below
substituting Date1 & Date2 for your date field names. Having time on the date
fields does not matter.
HowManyDays: DateDiff("d",Date1,date2)
 
G

Guest

Dennis said:
In the field row of a column in your query type in the line below
substituting Date1 & Date2 for your date field names. Having time on the date
fields does not matter.
HowManyDays: DateDiff("d",Date1,date2)

"popfun5" wrote:

Hi Dennis,

I did as instructed and when I leave that field I recieved the following
error message:

"The expression you entered contains invalid syntax.
You may have entered a comma without a preceding value or identifer"

Please HELP......

Thanks you much!
 
D

Douglas J. Steele

popfun5 said:
Hi Dennis,

I did as instructed and when I leave that field I recieved the following
error message:

"The expression you entered contains invalid syntax.
You may have entered a comma without a preceding value or identifer"

What are your regional settings? Sometimes you need to use a semi-colon
rather than a period:

HowManyDays: DateDiff("d"; Date1; Date2)
 
G

Guest

Douglas J. Steele said:
What are your regional settings? Sometimes you need to use a semi-colon
rather than a period:

HowManyDays: DateDiff("d"; Date1; Date2)


--
Doug Steele, Microsoft Access MVP

(no e-mails, please!)

Thanks, I got to calculate the difference in days but I need to calculate the time also within the two fields that contains both the date and time value.
 

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