kidrobot
05-22-2007, 10:06 AM
I have a query that I need to always pull data from the newest past 3 months, so if this query were ran today it would take from months 2,3,4 (Feb, Mar, Apr). Any clue on how to do this?
|
View Full Version : Query to pull past 3 months kidrobot 05-22-2007, 10:06 AM I have a query that I need to always pull data from the newest past 3 months, so if this query were ran today it would take from months 2,3,4 (Feb, Mar, Apr). Any clue on how to do this? rainman89 05-22-2007, 10:10 AM between dateadd("m",-3,date()) and date() kidrobot 05-22-2007, 10:34 AM That didn't work. Does any of that above correspond to a column name? rainman89 05-22-2007, 10:35 AM it should go in the criteria of your date column kidrobot 05-22-2007, 10:50 AM Yes, that is exactly where I placed it. kidrobot 05-22-2007, 10:56 AM I'm not sure if my question was clear, but the months are in the table so I only want the months 2, 3, 4. (that is how the months are displayed in the table also, just as numbers) rainman89 05-22-2007, 10:58 AM i just created a sample query and put this in and it worked. Between (DateAdd("m",-3,Date())) And Date() rainman89 05-22-2007, 10:59 AM oh.... i see now then the way i suggested will not work for u kidrobot 05-22-2007, 11:04 AM =( ... do you think it is possible then? rainman89 05-22-2007, 11:05 AM yeah. ull need to search on parsing dates to get the month number then base your query upon that boblarson 05-22-2007, 11:06 AM Then move to this (a variation on Ray's suggestion): Between Format(DateAdd("m",-3,Date()),"m") And Format(Date(),"m") kidrobot 05-22-2007, 11:09 AM sweet that works great, for some reason it pulls data from 2,3,4,5. So I just used 2 and it took 2,3,4. Thanks!~ kidrobot 05-22-2007, 12:42 PM Sorry but my Manger wants the past 3 months not including the current month. This Between Format(DateAdd("m",-2,Date()),"m") And Format(Date(),"m") ... works but it takes 3 months plus the current month, any idea on how to skip the current month? boblarson 05-22-2007, 12:44 PM Between Format(DateAdd("m",-2,Date()),"m") And Format(DateAdd("m",-1,Date(),"m") kidrobot 05-22-2007, 12:45 PM wow you're amazing... i gave you positive replutation points |