Link to home
Start Free TrialLog in
Avatar of Brogrim
BrogrimFlag for Ireland

asked on

Qury between 2 dates

I have a fiedl on a form, I wan to return all the records 21 days before that day

I gave tried <=Date() -21

and load others but can't get it working

Any ideas
Avatar of jorgedeoliveiraborges
jorgedeoliveiraborges
Flag of Brazil image

if FutureDate - getdate () <= 21 ...
Avatar of Brogrim

ASKER

I don't understand

I want all the records starting at the form field date and 21 days before that
Avatar of Patrick Matthews
Assuming this is Access, then you will need something like this in the WHERE clause of your query:

WHERE DateInTheTable <= (CDate(Forms![NameOfForm]![NameOfDateField]) - 21)

Open in new window

Avatar of Brogrim

ASKER

tried that with this SQL not working

SELECT tblddai_renewalpostdate.daterenewalposted
FROM tblddai_renewalpostdate
WHERE (((tblddai_renewalpostdate.daterenewalposted)=([Forms]![frmDDAI_SB]![txtStartDate])-21));
ASKER CERTIFIED SOLUTION
Avatar of Kevin Cross
Kevin Cross
Flag of United States of America image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
Avatar of Brogrim

ASKER

Thanks
You are most welcome! Note my comment was in support of Patrick's regarding CDate(). If that is what solved the issue, then please know you won't offend me any by requesting a Moderator change this to a split or credit to Patrick. If the DateAdd() is what did it, then glad that helped!

Best regards and happy coding,

Kevin