Exclude Holidays,Saturday and Sunday from Calender

Hi All,

Can any one help me to extract the 2 days older date from current date in calender excluding Holidays and weekends(Sat,Sun).
For Example: current date = 26/02/2024
result date = 23/02/2024

if in case 23/02/2024 is fall under holiday then

                  result date = 22/02/2024

Please guide me how to do this?

@yashashwini2322

resultDate = Enumerable.Range(1, 2 + If(DateTime.Now.DayOfWeek = DayOfWeek.Monday, 2, If(DateTime.Now.DayOfWeek = DayOfWeek.Sunday, 1, 0))).
             Select(Function(i) DateTime.Now.AddDays(-i)).
             FirstOrDefault(Function(d) Not (d.DayOfWeek = DayOfWeek.Saturday OrElse d.DayOfWeek = DayOfWeek.Sunday)).
             ToString("dd/MM/yyyy")

image

Hi @yashashwini2322

Assign resultDate = Now.AddDays(-2)
Check resultDate.DayOfWeek = DayOfWeek.Saturday
then resultDate=Now.AddDays(-1)
Else if resultDate.DayOfWeek = DayOfWeek.Sunday
resultDate=Now.AddDays(-2)

Thanks,
Lakshmi

Hi @yashashwini2322

Do you have the list of holidays in a excel.

Regards

yes.
Calender.xlsx (12.0 KB)

this is the sample calender for February 2024 with holiday and weekend list.the file will contains all the months data untill 2030.

1 Like

Hi @yashashwini2322

Check out the below xaml file. Hope this meets your requirement.

Sequence2.xaml (11.0 KB)

Regards

Can you zip the process and share it,not able to open it

Hi @yashashwini2322

Check the below zip file. Hope this meets your requirement.

BlankProcess18.zip (198.6 KB)

Regards

Sorry to mention,

for 20/02/2024 the result date should be 16/02/2024 but it is wrongly picking 17/02/2024

Hi @yashashwini2322

Check the below zip file. Hope this meet your requirement.

BlankProcess18.zip (214.3 KB)

Regards