Subtracting dates in query

rkrause

Registered User.
Local time
Yesterday, 16:21
Joined
Sep 7, 2007
Messages
343
I have a date field in a query and in the criteria part of it, i want to take todays date and only show in the query anything within in the last year 365 days.

i thought =today-365 would work but its not.

Thanks.
 
Date diff is difference between to dates, at least thats what i understand. But i wanna take the current date and subtract 365days or 1 year

DateDiff("d",Now(),365) - this didnt work...
 
Date diff is difference between to dates, at least thats what i understand. But i wanna take the current date and subtract 365days or 1 year

DateDiff("d",Now(),365) - this didnt work...




You can use Between Date() And Date()-365
 
The function you would have wanted was DateAdd() rather than DateDiff. Because of how dates are stored, the Date()-365 will generally work fine. I throw the function out there for those who might see this later and need some other unit of measure than days. In fact, you may want to subtract a year rather than 365 days, given the effect the occasional leap year will have. Depends on your specific needs.
 

Users who are viewing this thread

Back
Top Bottom