return records from some date and last 30 days

R

rascal

Hi all:
I thought I had solved this problem, but I have discovered I haven't. I
have a query where I want a prompt for the user to enter a date and have only
the records returned from the date entered and the previous 30 days. I had
entered the following in the crtieria field: >=DateAdd("d",-30,[Enter
StartDate]) but it returns records for dates afterwards. For example when I
entered Apr 13 I will also get records from Apr 14 up to today. What have I
done wrong and how do i correct it.
Thanks for your help.
 
J

John Spencer

You need to set a limit with a range.

Between DateAdd("d",-30,[Enter StartDate]) and [Enter StartDate])

That gives you a 31 day range (If you enter Dec 31 2006, the calculation returns
Dec 1 2006) so you get all records between midnight Dec 1 and midnight Dec 31.
If your date field contains times you will need to change the above to get
records for the end date.
 
R

rascal

Thanks so much John,
I tried it out and it works the way I want it to,


John Spencer said:
You need to set a limit with a range.

Between DateAdd("d",-30,[Enter StartDate]) and [Enter StartDate])

That gives you a 31 day range (If you enter Dec 31 2006, the calculation returns
Dec 1 2006) so you get all records between midnight Dec 1 and midnight Dec 31.
If your date field contains times you will need to change the above to get
records for the end date.
Hi all:
I thought I had solved this problem, but I have discovered I haven't. I
have a query where I want a prompt for the user to enter a date and have only
the records returned from the date entered and the previous 30 days. I had
entered the following in the crtieria field: >=DateAdd("d",-30,[Enter
StartDate]) but it returns records for dates afterwards. For example when I
entered Apr 13 I will also get records from Apr 14 up to today. What have I
done wrong and how do i correct it.
Thanks for your help.
 

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