How to add specific date + 10 days?

Hey,

I have a specific date like 02.08.18 and I wanna add 10 days on it to be 12.08.18

How to include cases if month or year will end by adding the 10 days?
For example:
29.08.18 plus 10 days should be 08.09.18

Thanks

If your date is variable type of DateTime, then you can just add it as date.AddDays(10).

Thanks,
Rammohan B.

1 Like

To convert your date string to a date time type, you will need to use DateTime.ParseExact() probably.

Look here for some examples:
https://forum.uipath.com/search?q=parseexact

Then just add the .AddDays(number)
The same method can be used to subtract days by making it negative.

Hey @ClaytonM
I am getting this error when trying to use DateTime.ParseExact()

what should I do?

Hey @Rammohan91

How to make the date variable type as DateTime? Thanks

Hey Mate,

I believe you are using a variable named CultureInfo. Check the scope of this variable. My guess is, it not accessible at point where you are trying to us it.

Hey, no I am not using a variable named CultureInfo. I thought maybe it’s a default system variable. Should I declare it?

Hi @UiMe

You need to either import the Namespace or use the full namespace infront of the CultureInfo. I think it is System.Globalization.CultureInfo

Oh, my bad. Let me try to create the same scenario.

Attached xaml file.
AddWorkingDays.xaml (11.9 KB)

You can change the default argument and run it.

1 Like

Can I pass 10 as variable?

Yes. You can assign 10 or any integer number to an integer variable & pass the variable to the function .AddDays().

Can you please show an example of syntax?

I want to add -10

Thank you. I am able to add 10 as variable.

2 Likes

there´s also a good way to add days from today: Date.Now.AddDays(-10).ToString(“dd/MM/yyyy”) don´t know if that will fit your need, though.

1 Like

Hello, sir I tried doing the same method you told but I am not getting ADD after typing the date.

hie so you hae a date in string format and you want to add 10 days right . so you have to take 3 assign activity 1 take your string date and in 2 assign you have to convert that date into date time for this >> DateTime.ParseExact(dd,“dd:MM:yyyy”,system.Globalization.CultureInfo.InvariantCulture) dd is string variable which holds the date like 25:12:2023
add days.xaml (7.3 KB)
here a sample attachment hope it will work