Solved

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

Posted on 2006-07-24
3
265 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
ID: 17167921
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
ID: 17168617
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
ID: 17170449
No probs!
0

Featured Post

Comprehensive Backup Solutions for Microsoft

Acronis protects the complete Microsoft technology stack: Windows Server, Windows PC, laptop and Surface data; Microsoft business applications; Microsoft Hyper-V; Azure VMs; Microsoft Windows Server 2016; Microsoft Exchange 2016 and SQL Server 2016.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Introduction The Visual Basic for Applications (VBA) language is at the heart of every application that you write. It is your key to taking Access beyond the world of wizards into a world where anything is possible. This article introduces you to…
It’s the first day of March, the weather is starting to warm up and the excitement of the upcoming St. Patrick’s Day holiday can be felt throughout the world.
Familiarize people with the process of utilizing SQL Server views from within Microsoft Access. Microsoft Access is a very powerful client/server development tool. One of the SQL Server objects that you can interact with from within Microsoft Access…
Using Microsoft Access, learn some simple rules for how to construct tables in a relational database. Split up all multi-value fields into single values: Split up fields that belong to other things into separate tables: Make sure that all record…

821 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