473,396 Members | 1,866 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,396 software developers and data experts.

Counting Weeks in MS Access

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
4 7183
CaptainD
135 100+
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
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
CaptainD
135 100+
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
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

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

Similar topics

9
by: David Poundall | last post by:
I have a thread class and I want to be able to track its usage within an application. FYI the class launches aplications in their own thread when the 'launch' method is called. That works OK ...
8
by: David Allison | last post by:
Hi, I need a Calculated Date = 4 weeks before Date which is in table ... How ? -- Dave Allison ~ Scotland
4
by: Alicia | last post by:
I am having a problem grouping by week. I am looking for the simpliest way of doing it in Microsoft Access. I have tried to use a pre-loaded calender, access did not like it at all. If there is...
18
by: ChadDiesel | last post by:
I appreciate the help on this group. I know I've posted a lot here the last couple of weeks, but I was thrown into a database project at my work with very little Access experience. No other...
4
by: aaronfude | last post by:
Hi, Please consider the following class (it's not really my class, but it's a good example for my question): class Vector { int myN; double *myX; Vector(int n) : myN(n), myX(new double) { }...
4
by: Dado | last post by:
I have a next situation with the textbox field: A - B = C 1. How to fill the A fill with the data from my previous recordset ? Can I do it with the expression builder ? 2. I want that every...
1
by: dlesandrini | last post by:
I've searched the archives, but not found anything on this, but our problem started only 2 weeks ago, so it might be very new. If anyone else has seen it, I would appreciate any feedback you have...
3
by: Libber39 | last post by:
Hi everyone, Have a query on how to calculate the amount of weeks and days contained in a number in an access query. ie: the difference in days between 2 dates amounts to 17 days. I want to now...
5
by: Brian S. | last post by:
Hi, I am trying to calculate the number of DayOfWeek in a month.. for instance.. this month April I want to know how many tuesdays there are in this month, this year I try to use where intDOW =...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
marktang
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,...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
Oralloy
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,...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
0
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...
0
agi2029
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,...

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.