Datetime expression

I want to obtain the day before today. Example: today is 23.12.2022 and i want 22.12.2022
How can i do?

Then, the day i obtain resting one day if its monday, i need to save in a list the day of friday, saturday and sunday.

How can i do that?

@amaia.aristeguii

Welcome to the community

Now.adddays(-1) will give you the previous date

And to get in required format use now.adddays(-1).Tostring("dd.MM.yyyy")

Remaining can you be more specific on what is needed

Cheers

Hi @amaia.aristeguii

You this expression to get the previous date?

Datetime.now.Adddays(-1).tostring("dd.MM.yyyy")

You if activity

now.DayOfWeek.ToString.contains("Monday")

image

Regards
Gokul

i need to save into array or list three differents dates.
example:
if Now.addday(-1) is 19.12.2022 = Monday
save
list = 16.12.2022,17.12.2022,18.12.2022

it is to use this dates for the future execution.

This previous date, how can i save in a list to use a for each activity?

@amaia.aristeguii

Create an array like this

{now.adddays(-1),now.adddays(-2),now.adddays(-3)}

Else create a liat and use add to collection/append to collection to add items to it

Cheers

UiPath is giving me error using ‘now’.

How can i fix it?

@amaia.aristeguii

Try datetime.Now

Cheers

image

image

@amaia.aristeguii

Are you using c# project?

Then try Datetime.Today.Addays(-1).ToString

cheers

same error.

Maybe some imports?¿

@amaia.aristeguii

Can you tell me what is the project type is it windows or C#?

If you write ‘datetime.’ is it showing any methods?

This is the complete namespace System.DateTime.Now Or Today both should work

I hope system is imported in the imports

cheers

Hello @amaia.aristeguii

You can use Modify Date activity to do the calculation on the date and then add that value to the list you can use “Append Item to collection” activity.

Thanks

is in c the project.


When i write appear everything but then give me a error.

@amaia.aristeguii

Please use like this

Convert.ToString(DateTime.Now.DayOfWeek).Contains("Monday")

Or

Convert.ToString(DateTime.Today.DayOfWeek).Contains("Monday")

Both would work

cheers

Thank you!

1 Like

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