Convert day.month.year in SAP as the Start and end date

Hi,

We are actually trying to convert the day 4 days before today
so would be something like in a string format like this
“Today(Day)-4”."Today(Month)-4days’.“Today(Year)-4days”
So we can have something like this by example
If today we are the 10.08.2020
I want UiPath to write 06.08.2020

We also want to take the Saturday in 6 weeks
So if today is 10.08.2020
We would like to day
CurrentDate+6 weeks (Day of Week) = Saturday
and convert it in thee same format with the dots which would result like this
26.09.2020

Thank you for your help and have a nice day :slight_smile:

Hi @BOYER_Tommy

Are you trying to do the below thing :-
Step 1

String str = DateTime.Now.ToString("dd.MM.yyyy")

Step 2

String fourDaysLess = CDate(str.Split("."c)(1)+"."+str.Split("."c)(0)+"."+str.Split("."c)(2)).AddDays(-4).ToString("dd.MM.yyyy")

Output :-

Workflow for the same :-
MainPratik.xaml (7.5 KB)

Mark as solution and like it if this helps you :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

1 Like

Hi Pratik,

it did work properly
However for getting the Saturday in 6 weeks how can I get my Saturday?

I think it would be something like this:
CDate(str.Split(“.“c)(1)+”.”+str.Split(“.“c)(0)+”.”+str.Split("."c)(2)).AddDays(42).ToString(“dd.MM.yyyy”)
This will go 6 weeks later, but how do I go specifically on the Saturday?
Can you help me out with this one too?

Thank you for your time

Tommy

Hi @BOYER_Tommy

Follow below steps :-

Step 1

Dictionary<String, Int32> dicOfWeek = New Dictionary(Of String, Int32) From {{"Sunday",-1},{"Saturday",0},{"Friday",1},{"Thursday",2},{"Wednesday",3},{"Tuesday",4},{"Monday",5}}

Step 2

String str = DateTime.Now.ToString("dd.MM.yyyy")

Step 3

String currentDateTillSixthWeek = CDate(str.Split("."c)(1)+"."+str.Split("."c)(0)+"."+str.Split("."c)(2)).AddDays(42).ToString("dd.MM.yyyy")

Step 4

DayOfWeek keyDayOfWeek = CDate(currentDateTillSixthWeek.Split("."c)(1)+"."+currentDateTillSixthWeek.Split("."c)(0)+"."+currentDateTillSixthWeek.Split("."c)(2)).DayOfWeek

Step 5

Int32 valueForDayOfWeek = dicOfWeek.First(Function(x)x.Key.ToString.Equals(keyDayOfWeek.ToString)).Value

Step 6

String saturdayDateOfSixthWeek = CDate(currentDateTillSixthWeek.Split("."c)(1)+"."+currentDateTillSixthWeek.Split("."c)(0)+"."+currentDateTillSixthWeek.Split("."c)(2)).AddDays(CInt(valueForDayOfWeek)).ToString("dd.MM.yyyy")

Below is the workflow for the same :-
Pratik.xaml (9.3 KB)

Output :-

image

Mark as solution and like it if this helps you :slight_smile:

Happy Automation :raised_hands:

Best Regards
Er Pratik Wavhal :robot::man_technologist:t4: :computer:

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