In this example, you will create an automation to store the current date and time in a variable, calculate a future date by adding a specified number of days, and log the variables in a file for verification.
Procedure
- Create an automation.
- On the left panel, click Automation.
A list of available bots and forms is displayed.
- Click Create a bot.
- Enter the bot name: Datetime-assign.
- Click Create and Edit.
- On the left panel, click Automation.
- Create the following user-defined variables using the Create
variable (+) icon at the top of the
Variables menu.
Variable name Variable type Default value Currentdate Datetime - Futuredate Datetime - - Double-click or drag the Assign action from the Datetime package in the Actions palette.
- From the Select the source datetime variable/ value, choose the Variable option.
- From the Variable tab, choose Variable and enter
$System:Date$.Note: You can use the System: Date variable to get the current date. In this example, the System: Date value is considered as 7/22/2024 07:00 AM IST (UTC+5:30) Calcutta, Asia
- In the Select the destination datetime variable field, select the Currentdate variable to store the system date.
- Double-click or drag the Add action from the Datetime package in the Actions palette.
- In the Source date and time variable field, choose the Variable option.
- In the Source date and time variable field, choose either
of the following options:
- Enter the date and time: You can enter the date
and time manually by choosing any of the following:
- Select a suitable format from the Prebuilt formats list. Enter the date and time in the exact same format. For example: If you choose ISO_LOCAL_DATE_TIME ('2011-12-03T10:15:30'), ensure the date-time is in the format 2011-12-03T10:15:30.
- Provide a custom format through any of the following date
pattern letters:
yyyyis the four-digit year,yyis the two-digit yearMMis the month number,MMMis the short month name (Jul),MMMMis the full name (July)ddis the day of the monthHHis the hour in 24-hour time,hhis the hour in 12-hour timemmis minutes,ssis secondsais AM/PMzorZis the time zone
MMmeans month butmmmeans minutes, andHH(24-hour) differs fromhh(12-hour). For example, to enter the date as 07/22/2024 07:00 AM, provide the Custom Formats as MM/dd/yyyy hh:mm a.
- Variable: Give a name to the variable.
- In the Variable field, enter $Currentdate$.
- In the Time value to add field, enter the value 7.
- In the Time unit to add field, select Days.
- In the Assign the output to a variable field, select the Futuredate variable to store the output.
- Enter the date and time: You can enter the date
and time manually by choosing any of the following:
- Log the current and future dates for verification.
- Double-click or drag the Log variables to file action from the Logging package in the Actions palette.
- In the Output file path field, enter
C:\Bot testing\logtofile.txt.Note: If a .txt file is not already available, create a new one.
- From the Variables to log field, choose Custom selection.
- Select the variables Currentdate and Futuredate.
- Click Save and then Run.
The bot logs the variables in the .txt file and displays the variables as follows: