Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Calculate Dates

Status
Not open for further replies.

nicolea

Instructor
Jan 21, 2004
9
US
I have a database the keeps records for insurance. I need show records that the insurance will exprire 60 days from now. I have a field for start date and end date aleardy popluated. I just can not figure out how to just show records when the end date will be 60-days from now.
 
something like this?

SELECT * FROM tblName WHERE EndDate = DateAdd("d",60,Date)


Leslie
 
I tried Now()+60 and I get all of my records. What does the "d" stand for?
 
d" tells the DateAdd function to add 60 days; if you put "m" it will add 60 months, q for quarter, y for year.

have you tried today instead of now? you may want to check the help on DateAdd to make sure I've got the syntax right.



Leslie
 
The propoed soloution will return ONLY those which are exactly 60 days away, not any which are less than this.




MichaelRed


 
Actually the () should be added
SELECT * FROM tblName WHERE EndDate = DateAdd("d",60,Date())

MichaelRed is correct that this solution meets the exact specifications of just 60 days out.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
Leslie,
You and I have been at this long enough that we understand what is required and what is asked for is not always the same.

Asking for a query that returns 60 days out assumes that someone runs this query every day of the year. Does this suggest that someone is working on all weekends and holidays? Maybe so, but I know my insurance man rarely works weekends and holidays.

Duane
MS Access MVP
Find out how to get great answers faq219-2884.
 
you're right, I wasn't thinking it completely through. And of course what is asked for isn't always what is needed, you are absolutely right there too. [hammer]

My apologies if I came across harshly, I didn't mean too. [blush]

Thanks for the (veiled) compliment, back at you.



Leslie
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top