473,378 Members | 1,110 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,378 software developers and data experts.

How to display 1 month's data per week in a report

547 512MB
I have data that i have to display in a report on a monthly basis but split up in weeks.
If a month has 28 days then the data will be split up day1 to day7 as week 1; day 8 to day14 as week 2; day15 to day21 as week 3 and day22 to day28 as week 5 etc.
If you have ie 30 days then a 5th week comes into play.
I will use a filter with a start and end date to get ie January 1 to January 31 data, to display.
My main fields in the query are

Month
Rxdate
Facility
PatientType (ie Diabetic or HIV)
Quantity

What i have done so far:
I have tried to calculate the week number and then sort it ascending. At the same time i use Totals and count to add up the Quantity field.

Is there not perhaps a way to sort data based on weeks dynamically and call it perhaps week 1; week 2 etc in that month
In my query i use this to get the week number based on the Rx date
Expand|Select|Wrap|Line Numbers
  1. WeekNum: DatePart("ww",[RxDate])
"Totals" are then used to add up the quantities for that specific week number.

The "weeknumber" is not what i would like to display in my report however.
Please assist
May 6 '13 #1

✓ answered by Rabbit

Sorry, forgot you need to subtract one from the day first.
Expand|Select|Wrap|Line Numbers
  1. (Day(dateValue) - 1) \ 7 + 1

6 3431
nico5038
3,080 Expert 2GB
First you need to decide which week the year is starting with.
Sometimes Access will return for 1-1-yyyy a weeknumber 53 (of the previous year), depending on the regional settings.

Personally I would create (e.g. from code) a steering tabel holding all dates with the all "DayDate", the weeknumber and the Month.

Now I would JOIN the RxDate with this table and a group by after filtering the Month will do the math for you, Including "split weeks" between months.

Getting the idea ?

Nic;o)
May 6 '13 #2
Rabbit
12,516 Expert Mod 8TB
Take the day, integer divide by 7, add 1. That will give you the week number starting with the the first day of the month.
May 6 '13 #3
neelsfer
547 512MB
thx guys but i am struggling along and want to make it uncomplicated but i am a bit thick i presume.
Is there not a way to design a query similar to this code on a form, that i can then filter and use in the report?
Expand|Select|Wrap|Line Numbers
  1. Dim t_Day As Double
  2. t_Day = Day(rxDate)
  3. Select Case t_Day
  4. Case 1, 2, 3, 4, 5, 6, 7, 8
  5. Me.txtboxweeknumber = 1
  6. Case 9, 10, 11, 12, 13, 14, 15, 16
  7. Me.txtboxweeknumber = 2
  8. Case 17, 18, 19, 20, 21, 22, 23, 24
  9. Me.txtboxweeknumber = 3
  10. Case 25, 26, 27, 28, 29
  11. Me.txtboxweeknumber = 4
  12. Case 30, 31
  13. Me.txtboxweeknumber = 5
  14. End Select
It would also help if i could get the "date period" for a week number. (ie 01 June to 07 June for week 26 perhaps)
May 7 '13 #4
Rabbit
12,516 Expert Mod 8TB
Did you try my suggestion?

Take the day, integer divide by 7, add 1.
Expand|Select|Wrap|Line Numbers
  1. Day(dateValue) \ 7 + 1
As far as your date period goes, that's a different question so it should be in a new thread because we only allow one question per thread. As a note though, there is no guarantee that the 26th week of a year starts with June 1st. The first week of a the month of June will always start with June 1st. But the 26th week of a year does not always start with June 1st.
May 7 '13 #5
Rabbit
12,516 Expert Mod 8TB
Sorry, forgot you need to subtract one from the day first.
Expand|Select|Wrap|Line Numbers
  1. (Day(dateValue) - 1) \ 7 + 1
May 7 '13 #6
neelsfer
547 512MB
thx rabbit it seems to do the trick
May 7 '13 #7

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: Jason Chan | last post by:
Some chinese characters data (in Big5 encoding) is stored in database. I tried to display the data in an aspx but the characters cannot display correctly. I tried anything I think is related: -...
5
by: RandyG | last post by:
how do you pull the current months data without having to manually input the date each time?
1
by: mviz | last post by:
I have a RS dataset that contains XML data, but when this data is displayed on the browser it shows as a string. I need help to display this data as a formatted XML document in browser. I have...
1
by: ganesah | last post by:
hi there, i need to create a program to continously display the received binary data (2bytes) from COM 8 in a console, however I'm having problem in doing so where i do nt see any data being...
1
by: EgoSum | last post by:
Does anybody can explain in steps how can I load xml data in report and open it in reportViewer? There's a short xml example ProductSales.xml: <?xml version="1.0" standalone="yes"?>...
6
by: jej1216 | last post by:
Using MySQL to store data that is in integer form. Need to display data as USD (such as $678,321 for the integer value 678321). Do I use PHP to do this or straight HTML? I have an HTML Form...
3
by: STEPHENSS | last post by:
Hi, I have a crystal report that has many subreports over many pages and Iam getting the following error Unable to save data with report, the save data is incomplete generate the saved data Yes...
19
by: Mel | last post by:
I want to display custom data in some sort of control on a web page. By custom data I mean it's not in a database yet it just resides in a List Box on a different tab . I just want to display the...
21
Mas Juliza Alias
by: Mas Juliza Alias | last post by:
Hi, I am building a program on Information System for Reservoir Operation for my Masters research. Now I have a text file which is an output file from a processing software (Terramodel) that lists...
1
by: Coolboy55 | last post by:
I'm sure this can't be as difficult as it seems, but I'm trying to create a simple chart in a report in Access 2003. The report is based on a query and I'd like to display the data in a chart. Any...
0
by: Faith0G | last post by:
I am starting a new it consulting business and it's been a while since I setup a new website. Is wordpress still the best web based software for hosting a 5 page website? The webpages will be...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 3 Apr 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 former...
0
by: taylorcarr | last post by:
A Canon printer is a smart device known for being advanced, efficient, and reliable. It is designed for home, office, and hybrid workspace use and can also be used for a variety of purposes. However,...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: aa123db | last post by:
Variable and constants Use var or let for variables and const fror constants. Var foo ='bar'; Let foo ='bar';const baz ='bar'; Functions function $name$ ($parameters$) { } ...
0
by: ryjfgjl | last post by:
In our work, we often receive Excel tables with data in the same format. If we want to analyze these data, it can be difficult to analyze them because the data is spread across multiple Excel files...
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
0
BarryA
by: BarryA | last post by:
What are the essential steps and strategies outlined in the Data Structures and Algorithms (DSA) roadmap for aspiring data scientists? How can individuals effectively utilize this roadmap to progress...
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.