w3hello.com logo
Home PHP C# C++ Android Java Javascript Python IOS SQL HTML videos Categories
Week number input returns crazy full week output

I'm having a hard time quickly following your code logic. So here's mine.

You could start by finding the first day of the first week of that year

    Dim d As New DateTime(year, 1, 1)

    d = d.AddDays(-d.DayOfWeek)

And then add the number of days (week_number -1) * 7

    d = d.AddDays((week_number - 1) * 7)

I do a -1 since I assume that week_number will be equal to 1 to get the first week. Since d is already equal to the first week, we start counting at 0.

To get the last day, just add 6 (or 7) days to the result





© Copyright 2018 w3hello.com Publishing Limited. All rights reserved.