Weekend Date Validations

Team,

I have a date as input.

  1. I want to find the input date is Saturday or Sunday.
  2. If it is Saturday (10-Aug-2019) i wanted to choose the previous date of Friday (09-Aug-2019)
  3. If it is Sunday (11-Aug-2019) i wanted to choose the previous date of Friday (09-Aug-2019)

Need help in achieving this.

Thanks,
Robotics

If you have DateTime that is (10-Aug-2019) you can use method of DateTime called DayOfWeek to store the value of the Day to a String, then check if that value is equal to Saturday of Sunday.

For Example try this > DateTime.Now.DayOfWeek.ToString >> it will give you monday

Try using this solution.

This will essentially fetch you the previous working day.
If you particulary need only Fridays, you can add an additional check to see .Dayofweek is Friday. Else loop again.

Pls Let me know if you have any queriesDecideT1.xaml (19.1 KB)

@ Sudhakar. I have created the below mentioned variables. Can you confirm its datatypes ?
tmpMinusOne (DateTime)
dateTminusOne (DateTime)
arrWeekDays (String)
listHolidays (?)
What should be the datatype for listHolidays? and do i need to make any changes further ?

tmpMinusOne (DateTime)
dateTminusOne (DateTime)
arrWeekDays (String array) – > You have {“saturday”,“sunday”} in this string variable
listHolidays (System.Collections.Generic.List) It is basically a holiday calendar that i have in the list(In case if my previous Friday is a public/regional holiday, bot should not be picking that date) If you do not require this check, you can remove that.

-Sudhakar

@Sudhakar : I need to provide the input where to provide it ?

You can use Assign activity above the flow chart

ex:

inputDatetime= date.today()
tmpminusone=inputDateTime.Adddays(-1)

You can pass tmpMinusOne to the flow chart… Which in turn returns you the result.

After Start i used assign which contains date.today(), followed by another assign for inputDateTime.Adddays(-1) which connects to decision (NOT a Saturday/Sunday).

For the above changes i am getting - System.Argument.OutOfRange.Exception

Could you please attach your Xaml or Post a screenshot of the xaml.?

-Sudhakar A.S

Hope this helps.

T-1.xaml (23.1 KB)

I held up with another priority work, will check this and let you know this T-1.xaml file

@Sudhakar based on the above T-1.xaml i have added ListOfHolidays excel file with header as ‘Holidays’ with input datas as
17-Aug-19
24-Aug-19
31-Aug-19

Added DataTable with single column as ‘Holidays’
Getting error as - System Argument Null Exception
Do i need to add anything else before running the file ?

Hi,
A screenshot of the error or your Xaml here would be great to help you out, as i am not sure where the error occurs.

ListOfHolidays.xlsx (9.2 KB) T-1.xaml (24.9 KB)

@ Sudhakar attached my xaml file. Kindly check.