Even though most of the date&time operations can be quite easily handled by VB functions, UiPath has also a nice activity that handles date&time modifications in a nice UiPath way.
So if you don’t really like writing pieces of code in endless Assign activities, here is the activity for you.
This activity takes input as a data type DateTime. This data type can be used even when you are not really working with time, but only with a date. Also, the Modify Date activity is only working with the date part of it. Natively, time is stored as 00:00:00,000 when it is not defined.
Thanks to this activity, you will be able to:
- Add or Subtract defined period of time (Days, Weeks, Months or Years)
- Find Next or Previous day of week (Such as find what date is for next Monday)
- Find First or Last Day of Week, Month or Year.
Use the “Add Modification” button. This can add as many adjustments to your input date as you wish. You can change their order by drag&drop. Setup of modifications is pretty simple.
With the “Test” button, you can run a quick test on what your modifications will do. After you click this button, a small window will popup.
Provide Date to test (by default today) and click Test.
You have two options. You can store the output again as a DateTime variable, or as a text (String). You can do both at once.
If you want to store the output as a text (String), you have to tick the checkbox “Format output as Text”.
Then the DateFormat property is applicable and you can select from one of the pre-defined date formats. You do it from the Properties panel or from the Activity itself. In each of them, it has a different view.
If you would like to use your own format, check the “Use Custom Date Format”. Then provide custom format to "Custom Date Format".
If you would like to know from what options you can build custom date format, read here:
I prepared for you an example with few different date time operations and variations.
You can download it for free here: 006_ModifyDateActivity.zip (36.5 KB)