DateDiff

A

ashley greene

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.
 
D

Douglas J. Steele

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)
 
S

Steve

Dim RegDateFromTable As Date
RegDateFromTable = DLookup("[RegDate]","MyTable")
If DateDiff("d",Date(),RegDateFromTable) < 30 Then
MsgBox "current date is less than 30 days from the regdate"
End If

PC Datasheet
 
S

SKaplan

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!)



ashley greene said:
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.
 
F

fredg

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!)

ashley greene said:
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.

This was answered in a different news group.
Please do not multi-post.
I would suggest you read the Netiquette published at:
http://www.mvps.org/access
for information about cross-posting and multi-posting and how to best
get responses in these news groups.
 
S

S_Kaplan

fredg said:
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.

This was answered in a different news group.
Please do not multi-post.
I would suggest you read the Netiquette published at:
http://www.mvps.org/access
for information about cross-posting and multi-posting and how to best
get responses in these news groups.
 
S

S_Kaplan

Thank you. When I post, an error message is returned saying my message was
not sent so I tried to send again, but continued to get a error when sending
message. But, the message ended up being posted. This is the reason for the
same message being repeated.

S_Kaplan said:
fredg said:
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.

:

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.

This was answered in a different news group.
Please do not multi-post.
I would suggest you read the Netiquette published at:
http://www.mvps.org/access
for information about cross-posting and multi-posting and how to best
get responses in these news groups.
 

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