calendar week

akim

Newcomer
Joined
Jul 6, 2003
Messages
10
Location
germany
hi,

i need a function to get the number of the week.
for example this week is the 29th.


can anyone help me??

thx,

akim
 
there may be a better way of doing this, but...
Visual Basic:
'cal1 is the Calendar control
        Dim d As Date = CType("1/1/" & DateAndTime.Now.Year.ToString, Date)
        Dim w As Long = DateDiff(DateInterval.WeekOfYear, d, cal1.SelectionStart.Date)
        MessageBox.Show(w.ToString)

btw, this is week 27
 
hi,

thx for your answer,

i heard that the calender week is different in many countries.
in germany at the moment we got the 28
in canada as you said is the 27.

so i think i should ask someone in a german forum.



akim
 
I think it may be affected by the day of the week the calendar control starts the week.

I started on Sunday.

[edit]I tested several days (as the FirstDayOfWeek) I got the same results[/edit]
 
Hmm, Select the following dates and see what you get...
Here are my results...

Jan 1 = 0
Jan 4 = 0
Jan 5 = 1
Jan 11 = 1
Jan 12 = 2
Feb 1 = 4

It seems that my zero should be a one, so your results are accurate.
 
Back
Top