Solved

Report to display Current Month Data and Previous X Month's data.

Posted on 2006-07-24
3
237 Views
Last Modified: 2011-10-03
I am building some reports of data that is entered each month.  I need to generate reports that contain the data for this month as well as the previous X months.  I am having trouble with building the subtraction of these dates.  I have a form with 3 dropdown menus.  One for month (Jan, Feb, ...) one for Year (00, 01, 02,...), and one for Number of months (1, 2, ...).

How can I build a query off this so that when I select Feb 06 and previous 4 months a query gives me reports for:
Feb06
Jan06
Dec05
Nov05  

Is there a way to subtract dates?

Thanks!
0
Comment
Question by:busbeead
  • 2
3 Comments
 
LVL 65

Accepted Solution

by:
rockiroads earned 500 total points
Comment Utility
You can make use of DateAdd

e.g
dateadd("m",-4,currdate)

"m" = months
-4 = back 4
currdate = based from this date

Now in your query, for your selected date that u want t check against, u can do a between
e.g.

where somedatefield between mydate and dateadd("m",-4,mydate)
0
 

Author Comment

by:busbeead
Comment Utility
That is exactly what I was looking for.  I had been trying to build all these stupid tables to figure this out.  Thanks so much for such a quick solution!
0
 
LVL 65

Expert Comment

by:rockiroads
Comment Utility
No probs!
0

Featured Post

Get up to 2TB FREE CLOUD per backup license!

An exclusive Black Friday offer just for Expert Exchange audience! Buy any of our top-rated backup solutions & get up to 2TB free cloud per system! Perform local & cloud backup in the same step, and restore instantly—anytime, anywhere. Grab this deal now before it disappears!

Join & Write a Comment

QuickBooks® has a great invoice interface that we were happy with for a while but that changed in 2001 through no fault of Intuit®. Our industry's unit names are dictated by RUS: the Rural Utilities Services division of USDA. Contracts contain un…
I originally created this report in Crystal Reports 2008 where there is an option to underlay sections. I initially came across the problem in Access Reports where I was unable to run my border lines down through the entire page as I was using the P…
As developers, we are not limited to the functions provided by the VBA language. In addition, we can call the functions that are part of the Windows operating system. These functions are part of the Windows API (Application Programming Interface). U…
Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

771 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question

Need Help in Real-Time?

Connect with top rated Experts

9 Experts available now in Live!

Get 1:1 Help Now