By using this site, you agree to our updated Privacy Policy and our Terms of Use. Manage your Cookies Settings.
434,677 Members | 1,076 Online
Bytes IT Community
+ Ask a Question
Need help? Post your question and get tips & solutions from a community of 434,677 IT Pros & Developers. It's quick & easy.

Counting Weeks in MS Access

P: 6
Does anyone know how to tell Access how to simply count the weeks in the year to date and display it? I need a count of the weeks in the year to date to average out some figures. What is the code to do this?
Apr 25 '06 #1
Share this Question
Share on Google+
4 Replies


100+
P: 135
Use the "Datediff" function. It returns a number depending on the interval you choose based off two dates and / or times.
I put this in a command_click event.

Expand|Select|Wrap|Line Numbers
  1. Private Sub Command0_Click()
  2. Dim iNumWeeks As Integer
  3. iNumWeeks = DateDiff("ww", "1/1/2006", Date)
  4. MsgBox iNumWeeks
  5. End Sub
  6.  
Apr 25 '06 #2

P: 6
Well thats helpful but I just want the number of weeks to show up on a report. What do put for code and where in the report design view?
Apr 26 '06 #3

100+
P: 135
Then you need to be more specific with your questions.

Does anyone know how to tell Access how to simply count the weeks in the year to date and display it? I need a count of the weeks in the year to date to average out some figures. What is the code to do this?
Well thats helpful but I just want the number of weeks to show up on a report. What do put for code and where in the report design view?
Where you put it depends on where you want it.

If it's in the detail section and part of each "line" of the report data then pull it in with the query that the report is based on.
(Datediff works in queries in MS Access: "SELECT [LastName], [TotalHours], DATEDIFF("ww", [Date1], [Date2]) AS NumberOfWeeks FROM YourTable")

If it's in a summary field, then we'll need to know what data field it will calculate on and the data that is in it. Example if each "line" in the detail section has a number of weeks as 1, 3, 4 etc. then you would just "=sum([detailfield])"
Apr 26 '06 #4

P: 3
Dear Experts

I need to count number of weeks to the currant date in the month. I am working according to the Arabic calendar which Saturday is the week first day and Friday is last day.

Example: if today date is 31 july 2007 then week number should be 5

I need this as I have to make a auto number.
I am working on Access 2003

Thanks
Jul 31 '07 #5

Post your reply

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