How to get the 1st and last days of the Last week as a date with assuming that first day of week Is Sunday and end of the week is on Thursday
so I want the date of the first week (sunday)
and date of the end of the week (Thursday)
How to get the 1st and last days of the Last week as a date with assuming that first day of week Is Sunday and end of the week is on Thursday
so I want the date of the first week (sunday)
and date of the end of the week (Thursday)
You can try this
firstDayOfLastWeek = DateTime.Today.AddDays(-(((DateTime.Today.DayOfWeek + 1) Mod 7) + 7)).Date
ForLastDate = firstdayOfLastWeek.Adddays(4)
Cheers
Thank u for your reply but it shows me wrong value
both , it should print 05.28.2023 and 06.01.2023
but it print 05.27.2023 and 05.31.2023
Please use
firstDayOfLastWeek = DateTime.Today.AddDays(-(((DateTime.Today.DayOfWeek + 1) Mod 7) + 7)).Adddays(1).Date
Last remains same
Cheers
forv todays date it works but if change the date to test another date show wrong value
Please try this one
firstDayOfLastWeek = DateTime.Today.AddDays(-(Cint(DateTime.Today.DayOfWeek)+ 7)).Date
Cheers
same , wrong value
it showld print 21May and 25 of may
Please use this for last sunday…my bad I gave a wrong one
lastSunday = currentDate.AddDays(-Cint(DateTime.Now.DayOfWeek)).AddDays(-7)
Cheers