Find All Weekends

Hi,

Can you try the following expression?

targetYear = 2024
targetMonth = 1

Then

arrDays = Enumerable.Range(1,DateTime.DaysInMonth(targetYear,targetMonth)).Where(Function(i) New DateTime(targetYear,targetMonth,i).DayOfWeek= DayOfWeek.Saturday OrElse New DateTime(targetYear,targetMonth,i).DayOfWeek= DayOfWeek.Sunday).ToArray()

If you need previous month, the following will help you.

targetYear =DateTime.Now.AddMonths(-1).Year
targetMonth = DateTime.Now.AddMonths(-1).Month

Sample
Sample20240108-1a.zip (2.7 KB)

Regards,

2 Likes