Jump to content
Xtreme .Net Talk

Recommended Posts

Posted

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

  • Moderators
Posted

there may be a better way of doing this, but...

'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

Visit...Bassic Software
Posted

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

  • Moderators
Posted

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]

Visit...Bassic Software
  • Moderators
Posted

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.

Visit...Bassic Software

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Paste as plain text instead

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...