WeekOfyear

  • Thread starter Thread starter Dag G
  • Start date Start date
D

Dag G

Hello!

I know there is a function to give me the result of the present weeknumber
of the year. Can anyone help me with this topic. I want it to response on a
buttonclick and then give me a messagebox returned with the present
weeknumber of the year.

Thank you in advance
D.G. Norway
 
Hi, Dag...

Try the following code:

Dim dt As Date = Today()
Dim WeekOfYear As Long = DatePart(DateInterval.WeekOfYear, dt)

Of course, you can change "dt" to be any date and it will return the
week of the year for that date.

Hope this helps!
 
Hello, look at The System.Globalization.GregorianCalendar Class:

Public Shared Function GetWeekOfYear(ByVal d As Date) As Integer
With New GregorianCalendar
Return .GetWeekOfYear(d, CalendarWeekRule.FirstFourDayWeek,
DayOfWeek.Monday)
End With

Ed
 
* "Dag G said:
I know there is a function to give me the result of the present weeknumber
of the year. Can anyone help me with this topic. I want it to response on a
buttonclick and then give me a messagebox returned with the present
weeknumber of the year.

Notice that .NET's methods to determine the week number are not
compliant to ISO 8601.
 
Back
Top