Condition - Help

Hi,

I need some help writing a condition to do the following:

So i need a condition that will either input the end of the month which is

New Datetime(now.year, now.Addmonths(-1).month, Datetime.Daysinmonth(now.year,now.addmonths(-1).month))

Or IF there are only 3 working days left in the month, the input needs to be changed to the 3rd working day of the next month which would be 04/09/2019 (Based on todays date)

Any ideas Community?

1 Like

Fine lets take like
use a if condition
Now.day = Datetime.DaysInMonth(now.year,now.month)-3 AND
Not Now.Adddays(3).Dayofweek.ToString.ToUpper.Equals(“SUNDAY”) AND
Not Now.Adddays(3).Dayofweek.ToString.ToUpper.Equals(“SATURDAY”)

if the above expression is true it will go to THEN part where we can use another IF condition with this expression for 3rd working day of the next month
New Datetime(now.year,
now.month,
NOT (New Datetime(now.year,now.addmonth(1),1).Day)+3)).Dayofweek.ToString.ToUpper.Equals(“SUNDAY”)
OR
NOT New Datetime(now.year,
now.month,
(New Datetime(now.year,now.addmonth(1),1).Day)+3)).Dayofweek.ToString.ToUpper.Equals(“SATURDAY”)

–and if this is getting satisfied it will go to THEN part where we can assign a string variable like this
in_strdate = New Datetime(now.year,
now.month,
(New Datetime(now.year,now.addmonth(1),1).Day)+3)).ToString(“dd/MM/yyyy”)
or it will go to ELSE part where we can use another assign activity with a string variable like
in_strdate = New Datetime(now.year,
now.month,
(New Datetime(now.year,now.addmonth(1),1).Day)+5)).ToString(“dd/MM/yyyy”)

–now finally in the outer if condition if the condition fails it will go to ELSE part where we can keep this expression you have already
New Datetime(now.year, now.Addmonths(-1).month, Datetime.Daysinmonth(now.year,now.addmonths(-1).month))

hope this would help you
Cheers @shawnmurray

2 Likes