ecorg911
01-08-2009, 12:00 PM
Hi, I am currently trying to get a query to only output data that was "added" to a table in the last three months.
I have produced the following, although it is a poor way of getting round the problem. Could someone help me create a more efficient query. E.g. so the database would automatically know the current date etc.
Between #01/09/2008# And #01/01/2009#
Any help would be greatly appreciated.
Thanks :)
pbaldy
01-08-2009, 12:04 PM
Try
Between Date() - 90 and Date()
or use the DateAdd function to get better precision on the 3 months than 90 days.
dkinley
01-08-2009, 12:06 PM
If it is always going to be 3 months ... well, there are several ways you can do this - here is one.
In the QBE, in another column add the following ..
DateDiff("m",[DateAddedFieldName],Date())
where DateAddedFieldName is the date field you are wishing to key off of. Then, in the criteria of that column, place ..
<3
This is aircode, please test before fully trusting.
-dK
ecorg911
01-08-2009, 12:30 PM
Thank you both for your input =), I will try out these methods now and let everyone know the results :)
Edit: tried pbaldy's solution and works great thanks!
I would have tried DK's, but I think it's a little beyond my knowledge of access ^_^ Thanks :)
dkinley
01-08-2009, 12:45 PM
Hehehe ... is okay, I was simultaneously posting and just threw one out there.
Regardless of how you got the answer, you got an answer and it is working for you. Thanks for responding!
-dK
pbaldy
01-08-2009, 01:01 PM
Muah-ha-ha, victory is mine! :p
As dk said, the important thing is you got an answer that works for you. Typically there are numerous ways of accomplishing a goal.