Change Date depending on Working days

Hi,

Currently Automating SAP, see image!
image
The field is always set to the last day of the month unless there are only 3 working days of the month left, when that is the case it would be changed to the first 3 working days of the next month.

Any ideas how i would achieve this?

Regards,
Shawn

1 Like

when we have more working days than 3 then what would be the condition
Cheers @shawnmurray

1 Like

Is there a way of telling UiPath to use the last day of month?
Thanks @Palaniyappan

1 Like

yah of course
to get the previous month last date
New Datetime(now.year, now.Addmonths(-1).month, Datetime.Daysinmonth(now.year,now.addmonths(-1).month))

Cheers @shawnmurray

1 Like

So that for example would give me 31/08/2019 as it is the last day of this month?

Thanks @Palaniyappan

yes
Cheers @shawnmurray

1 Like

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

Or IF there are only 3 working days left in the month, it needs to be changed to the 3rd working day of the next month which would be 04/09/2019

Thanks @Palaniyappan

@Palaniyappan Would you be able to provide some guidance on how i might achieve this?

Thanks,
Shawn

1 Like

Sorry for the delayed response
let me check once and try to reproduce
Cheers @shawnmurray

1 Like

Okay thanks!
@Palaniyappan

Have you had any luck with this?
Cheers @Palaniyappan

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
kindly try this and let know for any queries or clarification
Cheers @shawnmurray

1 Like

Hi @Palaniyappan ,

Thanks for your help as always!

How do i assign in the last else statement.
I will attach xaml for review.

I want to use this for a Type Into activity can this be done?

Thanks,
Shawn
Main.xaml (6.1 KB)

1 Like

Fine
Instead assigning it to a variable we can directly mention that to type into activity
Cheers @shawnmurray

1 Like

Hi @Palaniyappan

Can you please check this?
Main.xaml (7.9 KB)

Would you mind documenting what date each of the conditions would output?
Cheers

1 Like

Hi @Palaniyappan

Did you get time to check?
cheers :slight_smile:

1 Like

Hi @Palaniyappan,
would i be able to use this to display the date on the screen based on the condition?

Thanks,
Shawn

1 Like

Yah of course
We can use this String in the message box activity

Cheers @shawnmurray

1 Like

Can you please review my attached xaml from a few weeks ago on this thread?

Thanks @Palaniyappan

1 Like

Sure let me check once
Few mins pls
Cheers @shawnmurray

1 Like