Filtering dates in Access queries? - ms-access

I'm building a report for a client. The report is not very complicated, just shows a bunch of stuff requested by the clients. One of the things I'm stuck on is... I need to be able to search by Transaction that took place between today and 6 months back. So when user click on Transaction report, it only shows the last 6 months from today. Anyone have any idea? I'm trying to build a query with that criteria, but I have no idea how it should be.
Another part of the report lets the client choose dates for the report (FROM & TO) and that's not too bad because I'm passing these values to a blank form and then using them in the report. However, here I'm having a hard time figuring it out.

=DateAdd("m", -6, Date()) This fulfills the requirements in my application

Related

Multi-Valued date range parameter in SSRS reports

I was tasked with replacing old reports made in Crystal Reports since SSRS is the standard we are using. The core functionality of the new SSRS reports works fine but there's one thing missing. It's not insanely important but it's been bugging me. One of the tables in the database I'm working on tracks tasks that have been worked on and stores the Monday of the week they were completed on as a datetime, as well as time spent etc.
Currently my reports allow for the user to choose a start week from a list of Mondays, and an end week. This along with other things are sent to a stored procedure to get the data needed for the report, with the where clause including
AND (Table).WeekStartDate BETWEEN (#paramStartWeek) AND (#paramEndWeek)
In the older Crystal Reports ones the query and filtering is done entirely in the report instead of a stored procedure. It seems to allow a list of different, specific intervals. If I wanted info from two weeks of 2015 and then 5 weeks from 2018 to appear in the report (for some reason) I could keep adding intervals to a list.
Normally you could do something similar in SSRS by setting the parameter to accept multiple values and parsing the string it creates in the stored procedure, but if i selected multiple start and end dates as two separate parameters there would be nothing saying which start went with which end.
Most of examples of this I've seen only allowed for predetermined amounts of time ("One month ago, three months ago, a year ago") but I would like for it to be any week needed.
The person I'm doing this for would like most of the filtering done outside of the report, so I'm wondering if anyone knows an easy way to get a list of specific date ranges from SSRS into a stored procedure.

How do I write the Criteria in Query Design to equal last month's data?

I've looked on a couple different forums and I'm unable to find what I need they all have it listed in SQL View, and that is NOT what I want. I would like to do this in the Query Design as it is much easier for me.
I simply would like to make a query to display certain parameters of the database I maintain. And those parameters would equal last month's data.
I previously was able to successfully make a query displaying all information for the past year but can't figure out how to display just this past months.
The past year Criteria:
>DateAdd("yyyy",-1,Date())
Since that worked I tried doing this but it would not work for me:
>DateAdd("mmmm",-1,Date())
I'm sure it's something simple that I'm just not seeing here. Any help or recommendations are welcome.
Referencing the link provided by Fionnuala I have come up with
>DateAdd("m',-30,Date())
The problem being is that it queries all results for the past 30 days from Today's date. I wish to display only data from October ! While this can be done easily. I don't wish to manually go in this query every month and change certain parameters. I would like it to be automatic so or next month December I click on the query and it displays all 30 days of November's data. And there is no manual process of going back in and changing any of the criteria.
In the Query Designer you can use a Criteria: like this
>=DateSerial(Year(Date()),Month(Date())-1,1) And <DateSerial(Year(Date()),Month(Date()),1)
The corresponding SQL statement is
SELECT Donations.*
FROM Donations
WHERE (((Donations.DonationDate)>=DateSerial(Year(Date()),Month(Date())-1,1)
And (Donations.DonationDate)<DateSerial(Year(Date()),Month(Date()),1)));
If it was run on November 18, 2014 then it would effectively be
SELECT Donations.*
FROM Donations
WHERE (((Donations.DonationDate)>=DateSerial(2014,10,1)
And (Donations.DonationDate)<DateSerial(2014,11,1)));
Notes:
This query should be sargable and take advantage of an index on the date field (if one exists).
In case anyone is concerned about "month wrap-around", the DateSerial() function takes care of that for us. If the query was run in January 2015 then the first WHERE condition would indeed be ... >=DateSerial(2015,0,1) but that's okay because it returns 2014-12-01.

Creating an MS Access query based on system, status, and date

I am just learning Access and have been tasked with creating a database for system access. We need a report that shows what systems have been in a pending status for 0-30 days, 31-60 days, 61-90 days, and 91+ days. I am soooo close to getting this but I’m at a dead end. For the examples below I will just use NFC and eOPF as the systems (there are five systems in all).
So the report would read like this:
Pending Date...0-30...31-60...61-90...90+
NFC....................1.........4..........8........1
eOPF..................2.........5..........1........0
I have the table setup with a status field for each group (i.e. NFC Status = “Pending” or “Complete”)
I have another field that has a date submitted (i.e. NFC Submitted Date = “XX/XX/XXXX”)
This is what I have done. I am only sharing this to give an idea of the direction I was heading. If there is a better way please let me know.
I created two quires (NFC Requests & eOPF Requests)
The first row field in the query is the status (i.e. NFC Status) with Criteria =”Pending”
The second row is the 0-30 days with the field of NFC 0 - 30 Days: Sum((IIf([Systems Access - Table]![NFC Form Date Submitted]>Date()-31,1,0)))
The third row is NFC 31 - 60 Days: Sum((IIf([Systems Access - Table]![NFC Form Date Submitted]Date()-61,1,0)))
Etc, etc.
So I have two quires that give me that data I need and they work. Now, I need to figure out a way to combine the quires by changing the fields that calculate NFC and eOPF separately and calculate them together.
I tried to build a summary request report but it wants to push the totals for eOPF over and I can’t line them up.
It looks like this:
Pending Date...0-30...31-60...61-90...90+...0-30...31-60...61-90...90+
NFC....................1.........4...........8........1
eOPF..............................................................2.........5.........1.........0
I’m getting frustrated and could really use some help.
Justin
I think what you are looking for is a "crosstab" query google a nit and you'll find many good examples for ms access.
This is one that helped me alot.
http://www.paragoncorporation.com/ArticleDetail.aspx?ArticleID=25

Toggle between views

Good morning, I have recieved a rather odd reqeust. I currently have a report that is grouped by weeks. The customer loves the report but he would like a toggle option that would switch the view to months instead of weeks. I have never recieved this kind of request before and am not certain how to do this. Any assistance, direction, etc would be most appreciated.
My suggestion would be to prompt the user in the report to select a parameter on the weeks/month preference and then use an "IIF" in the group section of your table/matrix based on the parameter passed to group by the user selection (either Months or Weeks).

I want to display clients based on a five day week on a form (All 5 days at once)

I've got a list of clients who have certain tasks done on a weekly basis. Currently we use an excel spreadsheet that keeps track of this but I am in the works of automating it. In the process of moving this into our MS Access system, I have created a form that does this for a single day and can display a report that outputs in the manner I want the form to look but I cannot get the form to look like that so the user can see all the days of the week for all the clients at once. I suppose I could do this in a subform per client but it seems a bit messy...
The spreadsheet we currently use has Column headers that state the Date and the rows are sort of grouped up by client that are for the number of times the given action occured, the timestamp of when it happened and other various data that happened on that day.
For the life of me I cannot think of a way to view all the records for that given week, grouped in detail per client all at once on the form. I can think of some ways to do this through VBA with recordsets but would like to know is there is a simpler way to do this that is easier to maintain.
Is there a way to do this with the use of a query and a few small scale tricks that don't involve storing recordsets? Keep in mind that this is for Access 2000, I only wish we would upgrade to '03.
Why not use five subforms? One for today, another for tomorrow, etc for
the next five business days. – Tony Toews Sep 12 at 20:57
That is the answer I've gone with and it works BEAUTIFULLY with the setup we are using. Thanks for the wonderful idea!