How to get Saturday's and Sunday's of whole year

How to get all the Saturday’s and Sunday’s of the current year

1 Like

Hey @Shirin_Sebatina

Kindly try the below,

Assign Date Variable

DateVar = new Date(Now.Year,01,01)

Collection of weekend days for current year

Enumerable.Range(0, (DateVar.AddYears(1) - DateVar).Days).Where(Function(day) {6,0}.Contains(DateVar.AddDays(day).DayOfWeek)).Select(Function(day) DateVar.AddDays(day)).ToList

Demo Project nmnithinkrishna_CompareDTWithTwoColVal.zip (2.3 KB)

References

Hope this helps

Thanks
#nK

1 Like

Hi,

FYI, another solution:

arrayDateTime = Enumerable.Range(0,365-CInt(DateTime.IsLeapYear(Today.Year))).Select(Function(i) New DateTime(Today.Year,1,1).AddDays(i)).Where(Function(d) d.DayOfWeek=DayOfWeek.Sunday OrElse d.DayOfWeek=DayOfWeek.Saturday).ToArray()

Regards,

3 Likes

Hi! Welcome to community!

Make the appropriate post as solution and close the thread.

Regards,
NaNi

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.