Home > Mobile >  Finding the week number from a date in Visual Basic
Finding the week number from a date in Visual Basic

Time:02-04

I want to compare 2 dates and check that they are in the same week. Is there a way to find the week number of each date and compare them, or an alternative function to compare the dates and see if they're in the same week? Thank you :)))))))))))))))))

CodePudding user response:

Look at the vba Format function - use something like Format(DateVariable, "ww") to get week number of a date.

CodePudding user response:

Not sure why you tagged also VBA, but with .NET you would use Calendar.GetWeekOfYear:

Dim week = DateTimeFormatInfo.CurrentInfo.Calendar.GetWeekOfYear(DateTime.Now, CalendarWeekRule.FirstFourDayWeek, DayOfWeek.Monday)
  •  Tags:  
  • Related