Click here to Skip to main content
15,895,667 members
Please Sign up or sign in to vote.
0.00/5 (No votes)
See more:
Hi everybody, I am working on some project and I am almost finishing it but in the reporting phase I stacked. It is like this. The software (the project that I am working on) generates a report. The reporting service that I am using is Microsoft Report Viewer and I want to select and display all the customers that purchased items last month, from a single table into the report. Remember the report is going to be generated every month.
Posted
Updated 13-Mar-10 8:54am
v2

1 solution

redietlove wrote:
I want to select and display all the customers that purchased item last month


You need to write a SQL query on that table that will always return the records of 'last month'. Thus, whenever report is run, you get today-30 days data.

Set this (last month) parameter in your query the way you want.
1. You want last 30 days or so (has to be a fixed number).

2. Last month only. If today is 13th March, yet result set needs to be of just 1-28 Feb.

Accordingly, fetch the result with your appropriate WHERE clause.
Example:

SQL
Select 
   Id, Item, PurDate, Price 
From 
   PurTable 
Where 
   PurDate Between GetDate() AND (GetDate()-30)


redietlove wrote:
remember the report is going to be generated every month.

This part can be handled by your report server. Schedule it to generate and send it to users.
 
Share this answer
 
v2

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900