Hi,
This is probably easy but I’m can’t find the answer. I’m using Access 2003 (mdb).
Ok Here is my Issue I’m running a crosstab query to retrieve data for the Last 13 weeks from a single date field.
I can get the data using the Parameters:
WHERE ((([DATE]-Weekday([DATE])+1) Between Date()-96 And Date()-7))
This will work but on some days I get the current week.
I tried Between Week()-14 And Week()-1)) and I tried Between Weekly()-14 And Weekly()-1)).
With Both I get a “Undefined Function ‘Week’ in Expression” Error. So my Question is there a Week function for parameters?
If not any recommendations for the parameter?
Not a big deal for me now but I’m running this expression in 30 or 40 queries and I want it to be efficient and get it right the first time.
Thanks,
Boxcar
7 3669 MMcCarthy 14,534
Recognized Expert Moderator MVP
Hi Boxcar
I'm not sure exactly what you are looking for but try something like this ... -
WHERE DateDiff("w", [Date], Date()-(Weekday(Date())+1)) <= 13
-
That is what I was looking for!!!!!! (well kind of)
But it is pulling this weeks (the current week) data as well.
So today is 5/29 now I get 5/27 and twelve other weeks.
But I need 5/20 and twelve weeks back.
I keep trying different expression, but none work. I’ll probably get it.
But if anyone know an easy way please post it.
Thanks!
MMcCarthy 14,534
Recognized Expert Moderator MVP
Try this ... -
WHERE DateDiff("w", [Date], Date()-(Weekday(Date())+8)) <= 13
-
Sorry to bother you.
I feel like an Idiot +8 made sense. But now I get days going back 13 weeks. Here is the code TRANSFORM Sum(DailyCSTMs.COUNT) AS SumOfCOUNT
SELECT DailyCSTMs.CATEGORY, Sum(DailyCSTMs.COUNT) AS Total
FROM DailyCSTMs
WHERE (((DateDiff("ww",[Date],Date()-(Weekday(Date())+8)))<=13))
GROUP BY DailyCSTMs.CATEGORY
PIVOT DailyCSTMs.DATE;
Not sure if I mentioned this but as you can see it is a Crosstab Query.
And each record in the DB is by individual date.
It works this way I was just trying to find a better way: TRANSFORM Sum(DailyCSTMs.COUNT) AS SumOfCOUNT
SELECT DailyCSTMs.CATEGORY, Sum(DailyCSTMs.COUNT) AS Total
FROM DailyCSTMs
WHERE ((([DATE]-Weekday([DATE])+1) Between Date()-96 And Date()-7))
GROUP BY DailyCSTMs.CATEGORY
PIVOT [DATE]-Weekday([DATE])+1;
I'm Trying to make it Idiot Proof. Because I have Many reports running this query (and similar ones) at different time of the week.
I think one i got works fine.
mmccarthy If you have any Ideas or a better soulution it is appreicated.
Thansk you this site is great !!!
MMcCarthy 14,534
Recognized Expert Moderator MVP
Try keeping the same pivot at the old query. -
TRANSFORM Sum(DailyCSTMs.COUNT) AS SumOfCOUNT
-
SELECT DailyCSTMs.CATEGORY, Sum(DailyCSTMs.COUNT) AS Total
-
FROM DailyCSTMs
-
WHERE (((DateDiff("ww",[Date],Date()-(Weekday(Date())+8)))<=13))
-
GROUP BY DailyCSTMs.CATEGORY
-
PIVOT [DATE]-Weekday([DATE])+1;
-
For some Reason that query had 16 weeks including this week.
With some trial and error. I don't know why or how.
I got this to work: TRANSFORM Sum(DailyCSTMs.COUNT) AS SumOfCOUNT
SELECT DailyCSTMs.CATEGORY, Sum(DailyCSTMs.COUNT) AS Total
FROM DailyCSTMs
WHERE (((DateDiff("ww",[Date],Date()-(Weekday(Date())+1)))>-1 And (DateDiff("ww",[Date],Date()-(Weekday(Date())+1)))<=12))
GROUP BY DailyCSTMs.CATEGORY
PIVOT [DATE]-Weekday([DATE])+1;
It may not be the best but is works.
Thank You Very Much !!!!!!
MMcCarthy 14,534
Recognized Expert Moderator MVP
For some Reason that query had 16 weeks including this week.
With some trial and error. I don't know why or how.
I got this to work: TRANSFORM Sum(DailyCSTMs.COUNT) AS SumOfCOUNT
SELECT DailyCSTMs.CATEGORY, Sum(DailyCSTMs.COUNT) AS Total
FROM DailyCSTMs
WHERE (((DateDiff("ww",[Date],Date()-(Weekday(Date())+1)))>-1 And (DateDiff("ww",[Date],Date()-(Weekday(Date())+1)))<=12))
GROUP BY DailyCSTMs.CATEGORY
PIVOT [DATE]-Weekday([DATE])+1;
It may not be the best but is works.
Thank You Very Much !!!!!!
You're welcome. If it works don't mess with it :)
Sign in to post your reply or Sign up for a free account.
Similar topics |
by: Bryan |
last post by:
I've been looking over this newsgroup, but I can't find an answer to my
problem. I see that a few others have posted this issue over the
years, but none of them got a response. I'll give it another shot.
I have a report that is based on a crosstab query. The crosstab query
is based off of another query, and that has a parameter in the...
|
by: newguy |
last post by:
I am trying to get the totals of a table by client by type of income.
This query will get what I am looking for with each unique combination
as a row:
SELECT Sales.Client, BillCode.Type, Sum(Sales.Amount)
FROM Invoice_Details INNER JOIN BillCode ON Sales.BillCode =
BillCode.id
GROUP BY Client, Type;
|
by: Penny |
last post by:
(Access 2003 Multiuser Split DB, Windows XP Pro)
Hi All,
I would really appreciate just some basic tips on how to make a Crosstab
Form based on a Crosstab Query. The query always has the same number of
records(generated from a table of predefined 'timeslots'). The number of
columns(one for each Consultant) varies depending on how many of...
|
by: Tina |
last post by:
My employer tracks productivity/performance of clinicians (how much
they
bill) each week, its averages for the month, and the 6 months.
These averages are compared to their expected productivity.
However, the expectation changes - it may be 60% for a while, then
change to
50%. Initially, I was averaging the expectation, along with the...
|
by: Michael R |
last post by:
Please help me with this.
I have a form in which I would like to present results from a CrossTab query in a subform. I don't need the query to be bounded to a master field. Also, I have a parameter in the query as one of the main form controls. Please look at the query:
PARAMETERS !! Long;
TRANSFORM Sum(LoansSumAmountAndYearAndCity.Amount)...
| |
by: m.wanstall |
last post by:
I have a crosstab query that compiles data for Months of the year. I
have a stacked select query on top of that crosstab query that uses
the latest 2 months data and exports it to a fixed length flat file.
Ideally I would like to be able to just select the Last 2 Columns of
the Crosstab query as inputs to the Select query WITHOUT having to go...
|
by: odavison |
last post by:
I've created a Crosstab Query displaying the Consultant ID and the corresponding amount of Appointments they have on a specific date, as well as a count of the number of appointments.
I am trying to get it to display as a subform in the Consultant Form, and I have read around stating that you need to declare your parameters in order for it to...
|
by: lisacrowe |
last post by:
I have a simple database recording complaints. A crosstab query is based on a query which returns resolved complaints only. The crosstab has the field Complaint Type as a row heading and Outcome as a column heading.
I want to be able to select complaints which were resolved in a particular date range (field is Date resolved). This field is in...
|
by: ollyb303 |
last post by:
Hello,
I am using a dynamic crosstab report to track performance statistics for my company and I have hit a problem.
I would like the option to track stats daily (for the last 7 complete days), weekly (for the last 6 weeks) and monthly (for the last 6 complete months).
Daily and monthly are not causing me a problem - I have used the...
|
by: marktang |
last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However, people are often confused as to whether an ONU can Work As a Router. In this blog post, we’ll explore What is ONU, What Is Router, ONU & Router’s main...
|
by: Oralloy |
last post by:
Hello folks,
I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>".
The problem is that using the GNU compilers, it seems that the internal comparison operator "<=>" tries to promote arguments from unsigned to signed.
This is as boiled down as I can make it. ...
| |
by: Hystou |
last post by:
Overview:
Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows Update option using the Control Panel or Settings app; it automatically checks for updates and installs any it finds, whether you like it or not. For...
|
by: tracyyun |
last post by:
Dear forum friends,
With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each protocol has its own unique characteristics and advantages, but as a user who is planning to build a smart home system, I am a bit confused by the...
|
by: agi2029 |
last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing, and deployment—without human intervention. Imagine an AI that can take a project description, break it down, write the code, debug it, and then...
|
by: isladogs |
last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM).
In this session, we are pleased to welcome a new presenter, Adolph Dupré who will be discussing some powerful techniques for using class modules.
He will explain when you may want to use classes...
|
by: conductexam |
last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and then checking html paragraph one by one.
At the time of converting from word file to html my equations which are in the word document file was convert...
|
by: muto222 |
last post by:
How can i add a mobile payment intergratation into php mysql website.
| |
by: bsmnconsultancy |
last post by:
In today's digital era, a well-designed website is crucial for businesses looking to succeed. Whether you're a small business owner or a large corporation in Toronto, having a strong online presence can significantly impact your brand's success. BSMN Consultancy, a leader in Website Development in Toronto offers valuable insights into creating...
| |