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

How to get the week number of the current month in C#

62
Hey gang

Need some help please. Below I have code which returns the week number of the year.

I need some code which simalarly return the week number of the current month.

dtDate below gets passed a date picked from a datepicker.

public static int GetWeekNumber(DateTime dtDate)
{
CultureInfo ciCurr = CultureInfo.CurrentCulture;
int weekNum = ciCurr.Calendar.GetWeekOfYear(dt, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday);

return weekNum;

}

Thanks,

Lóan.
Mar 7 '08 #1
1 24829
Plater
7,872 Expert 4TB
Why not just take the "day" value, which would be 7 today.
If you just need the number of "seven days" you are into a week, you could divide by 7.
If you need the ACTUAL "weeks" (like since march of this year started on a saturday, then march2nd was "week two") you might need a day of week for the 1st of the month to determine it?
Surely you could compute the week in the month from that?
Mar 7 '08 #2

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

Similar topics

4
by: Shahid Juma | last post by:
Hi, I am trying to figure out a way to get the week number of the current week. I know this is relatively easy using the calendar year (starting from January to now). However, I want to do it so...
1
by: josepe | last post by:
Hello, I need know the week nuber of the month. I know the function datepart() but returns the week number of the year a number between (1,53) I need a number between (1,4 o5). There is a...
7
by: Shuffs | last post by:
Could someone, anyone please tell me what I need to amend, to get this function to take Sunday as the first day of the week? I amended the Weekday parts to vbSunday (in my code, not the code...
10
by: Jim | last post by:
I'm sure this has been asked before but I can't find any postings. I have a table that has weekly inspections for multiple buildings. What I need to do is break these down by the week of the...
1
by: kennyscripts | last post by:
Hi Friends...... How to get the current month and current week in vb.net 2003 Can view the month textbox details and can only enter the week detail. How to get? Anybody knows give the answer....
1
by: hisham123 | last post by:
hi, can i get query to find the week of month for any given date for example date 03-aug-2007 is 1st week in the month, 10-aug-2007 is the 2nd week in the month, 19-aug-2007 is 3rd week in the month....
5
by: Michael R. Copeland | last post by:
I need to determine a given date's week number, but my searches of google only confuse and frustrate me: there are many apparent formulas (which are pretty complex) and they all seem to require...
1
by: guyborn | last post by:
I have been trying to get data from the database from the of the previous month to the second last week of the current month.I only managed to get data from the previous month to today's date. ...
5
by: xraive | last post by:
I would like to know if there is a function available to determine the week number in any given month. For example March 20th, 2010 would be Week #3
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: 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...
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
1
by: Sonnysonu | last post by:
This is the data of csv file 1 2 3 1 2 3 1 2 3 1 2 3 2 3 2 3 3 the lengths should be different i have to store the data by column-wise with in the specific length. suppose the i have to...
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...
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
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
tracyyun
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...

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.