Calendar Control

T

thomson

Hi all,
How will i able to know which week does the day falls.Is
there any method, which allows you to get


For eg:
Mon Tue Wed Thu Fri Sat Sun
1 2 3 4
5 6 7 8 9 10 11


If i give 3 it should give 1st week, and if i
give 8 it should give 2nd week

Regards

thomson
 
H

haile

Thomson:

Use DayOfWeek to determine how many days belong to the previous month. Then
add that number, whatever it is, to the current day and factor the sum by
seven to get the week of the calendar.

For example, here is how you would find the trailing days of November in
December's calendar:

DateTime d = new DateTime(2004,12,1);
int iTrailingDays = 0;
switch (d.DayOfWeek.ToString().Trim())
{
case "Monday":
iTrailingDays=1;
break;
case "Tuesday":
iTrailingDays=2;
break;
case "Wednesday":
iTrailingDays=3;
break;
...
}

Now to find out which week 12/5/2004 falls in, you would add 3 to 5, which
would put the fifth of December in the second week (because 8/7>1). Not
pretty, but it works.

Haile
 

Ask a Question

Want to reply to this thread or ask your own question?

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Similar Threads


Members online

No members online now.

Forum statistics

Threads
474,438
Messages
2,571,699
Members
48,796
Latest member
Greg L.
Top