Calculating the Difference Between 2 General Dates

M

Matt

This article (http://www.accessmvp.com/djsteele/Diff2Dates.html), which was
mentioned in a previous answer, details how exactly I want to have my answer
formatted. I entered this code into a new Module adjusting names to match my
fields, but the answer returned was "#Name?" I checked the field names and
they are correct. Can you tell me where/how this code should be entered
into my database (Access 2003)? Do i have to adjust names in the actual code?

I am trying to calculate the difference between the data entered in two text
boxes: Dateassigned and Datedue. I would like my answer in Days, Hours:
minutes format.
Dateassigned = 7/2/08 1:00 PM
Datedue = 7/7/08 09:00 AM

Thank you
 
K

KARL DEWEY

You need to use the syntax as below --
=DateDiff("n",[Forms]![YourEntryForm]![Dateassigned],[Forms]![YourEntryForm]![Datedue])

Then you need to convert the minutes to your desired display.
 
B

Beetle

That code should be placed in a global module exactly as is. You should
not make any changes to the code itself. You supply the date variables
when you call the code, along with the optional argument to show zero's

so when you call the code in, for example, a form module you would put

Diff2Dates("hns", [YourFirstDateField], [YourSecondDateField])

This would display the difference in hours, minutes and seconds, but would
exclude any values that are zero. If you want to show the zero values you
would put;

Diff2Dates("hns", [YourFirstDateField], [YourSecondDateField], True)
 

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