access question.

stevedave

Supreme [H]ardness
Joined
Mar 6, 2007
Messages
5,737
Ok I am importing from a large table into a smaller table and I need to have it dynamicly pull data 1 month back and 1 month forward from today.

Currently I am doing a between Date1 and Date 2 but I have to run this weekly and every week I have to change Date 1 and Date 2. So If I could just simple tell it to Pull Month -1 and Month +1 or something like that in the criteria that would be nice.

Anyone have a suggestion?
 
Yup.. the "Now" function returns the current datetime.
 
That much is a given, but how do I pull a month ahead of "now" and a month behind "now"?
 
The DateAdd function.

DateAdd(interval, number, date)

Setting Description
yyyy Year
q Quarter
m Month
y Day of year
d Day
w Weekday
ww Week
h Hour
n Minute
s Second

dateadd("m", 1, NOW)
dateadd("m", -1, NOW)

Of course you will have to clean up the time of the date time..
 
I'll give it a try in a bit, if it works it will be far more easy than the route I was going.

Thanks a bunch if I get this working I can offset the task to a monkey.
 
It's what we use for our reports so you shouldn't have a problem.
 
You are the bee's Knee's man. Now I'm going to offload this work to someone else.

thanks again.
 
Back
Top