By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
454,217 Members | 1,297 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 454,217 IT Pros & Developers. It's quick & easy.

Simple Query Help Needed

P: n/a
I have a table called tbl_employers. One of the fields is start_date.
I'm trying to make a query that will show all entries where todays date
is 275 days and 305 days after the start date.

Any help would be appreciated

Nov 13 '05 #1
Share this Question
Share on Google+
5 Replies


P: n/a
On 3 Nov 2005 08:20:23 -0800, em**********@gmail.com wrote:
I have a table called tbl_employers. One of the fields is start_date.
I'm trying to make a query that will show all entries where todays date
is 275 days and 305 days after the start date.

Any help would be appreciated


Do you mean between 275 and 305 days?

Select tbl_employers.* From tbl_employers
Where tbl_employers.[Start_Date] Between DateAdd("d",-275,Date()) and
DateAdd("d",-305,Date())

or exactly 275 and exactly 305 days?

Select tbl_employers.* From tbl_employers
Where tbl_employers.[Start_Date] = DateAdd("d",-275,Date()) Or
tbl_employers.[Start_Date] = DateAdd("d",-305,Date())

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Nov 13 '05 #2

P: n/a
Good point. I was planning on having them run the query every day but
that would not cover weekends.

Basically I needed a query that shows what entries are 90 days from
expiration , what ones are 60 days from expiration and what ones are
365 days or more.

The 365 or more was easy it's the other two that are causing problems
for me. I'll try your code samples. I'm using

DateDiff("d",[SHARP Begin Date],Now())
Then using >=365 for the expired ones
=274 for the 90 Day warnings which also bring the ones that are over a year old and I don't want them
and lastly
=305 for the 60 day warnings which is also bringing the ones that expire in 90 days and expired ones.


Nov 13 '05 #3

P: n/a
On 3 Nov 2005 12:47:51 -0800, em**********@gmail.com wrote:
Good point. I was planning on having them run the query every day but
that would not cover weekends.

Basically I needed a query that shows what entries are 90 days from
expiration , what ones are 60 days from expiration and what ones are
365 days or more.

The 365 or more was easy it's the other two that are causing problems
for me. I'll try your code samples. I'm using

DateDiff("d",[SHARP Begin Date],Now())
Then using >=365 for the expired ones
=274 for the 90 Day warnings which also bring the ones that are over a year old and I don't want them


and lastly
=305 for the 60 day warnings which is also bringing the ones that expire in 90 days and expired ones.


Using Now() in the expression is not a good idea.
Now() includes a time value, therefore the number of records returned
will depend upon the time of day the query is run.
Use Date() instead.

--
Fred
Please respond only to this newsgroup.
I do not reply to personal e-mail
Nov 13 '05 #4

P: n/a
Thank you for thaty suggestion I'm going to change them to Date.

How would I write the expression 61 to 90 days instead of just 90 days?

Nov 13 '05 #5

P: n/a
Scratch that. I figured out I can use <= at the end of the expression
to limit what shows and it all looks good.

Thanks for all the help Fred. I hope this helps others as well

Nov 13 '05 #6

This discussion thread is closed

Replies have been disabled for this discussion.