I am new to Access and am also tryng to accomplish the same thing. I have
read as much as I can in the posts related ot DateDiff, but I really don't
understand how to do it and would appreciate some help. I have created a
form that has two time/date fields. I wasn to add a third field that
calculates and displays the number of days between?
What I have done so far:
1) In the table design view for the form, which is called DDForm2648, I have
inserted a row and called the Field Name 'DateDiff', in the Data Type, I put
'number' (I didn't type in the ' marks). Then in the field properties box, I
clicked in Default Value and then clicked on the button with the three dots.
I then clicked on the little + to the left of functions and then on the
folder beside Built-In Functions, then Date/Time, then DateDiff and then
clicked paste. Then I changed what appeared in the Expression Builder window
to look exactly like this:
DateDiff ("d"[ExpectedSeparationDate],[DateChecklistPrepared])
I then clicked okay. Then I tried to click the save icon but I get the
following message:
The database engine does not recognize either the field
'ExpectedSeparationDate' in a validation expression, or the default value in
the table 'DDForm2648'.
I'm just shooting in the dark here. I have absolutely no clue what I'm
doing, I'm just trying to follow what I've read in other posts, but it's all
very, very confusing. Can someone please give me ...a simple step by simple
step?
Thank you very much.
Douglas J. Steele said:
It's not clear from your description whether regdate is in the past, or in
the future. I'm going to assume it's in the past: if I'm wrong, simply
reverse things in the examples I give.
The DateDiff function will calculate the difference between two dates:
DateDiff("d", [regdate], Date()) will give you the number of days between
the dates.
Another option is to use the DateAdd function to add 30 days to regdate, and
compare that to the current date. DateAdd("d", 30, [regdate]) will do that
(using -30 instead of 30 will subtract 30 days)
--
Doug Steele, Microsoft Access MVP
(no e-mails, please!)
I am using access 2000 and need the syntax to determine if
the current date is less than 30 days from the regdate
(date from a field in a table).
Thanks for your help.