While working on a project recently we had to generate reference numbers which included the week number of a given date. After tearing what's left of my hair out, and believe me there isn't much left, I asked a friend who pointed me in the direction of the DatePart function in VB.NET. This is an absolute life-saver.
Example:
Dim d As Date
d = Date.Today
Dim WeekNumber As Integer = vb.DatePart(DateInterval.WeekOfYear, d)
This assigns the week number for todays' date to the WeekNumber variable.
No comments:
Post a Comment