Date Manipulation in Automation Anywhere A360
Dates are an integral part of many automation processes. Whether you're scheduling tasks, generating reports, or processing data, understanding how to work with dates effectively is crucial. In this blog post, we'll explore how to manipulate dates in Automation Anywhere A360, focusing on finding the current date, the first day of the month, and the last day of the month.
Getting Started with Dates in Automation Anywhere
Automation Anywhere provides several commands and functions to handle dates. The core command you'll be using is the Get System Date/Time command. This command allows you to retrieve the current system date and time, which can then be manipulated as needed.
Finding the Current Date
To obtain the current date, follow these steps:
- Create a new action: In your Automation Anywhere bot, create a new action.
- Add the 'Get System Date/Time' command: Drag and drop the 'Get System Date/Time' command into your action.
- Configure the command: Specify the desired output format for the date. Common formats include:
yyyy-mm-dd
: Year, month, and day separated by hyphens (e.g., 2023-11-24)mm/dd/yyyy
: Month, day, and year separated by slashes (e.g., 11/24/2023)dd/mm/yyyy
: Day, month, and year separated by slashes (e.g., 24/11/2023)
Finding the First Day of the Month
Determining the first day of a month involves some date calculations. Here's a general approach:
- Get the current date: Use the 'Get System Date/Time' command to obtain the current date.
- Extract the year and month: Extract the year and month from the current date.
- Create a new date: Construct a new date using the extracted year, month, and the day set to 1. This represents the first day of the month.
Finding the Last Day of the Month
Calculating the last day of a month requires considering leap years. Here's a common method:
- Get the first day of the next month: Determine the first day of the following month using the techniques mentioned above.
- Subtract one day: Subtract one day from the first day of the next month to obtain the last day of the current month.
Additional Date Manipulations
While this blog post focuses on basic date operations, Automation Anywhere offers more advanced functionalities. You can:
- Calculate date differences
- Add or subtract days from a date
- Convert between different date formats
- Extract specific date components (year, month, day, hour, minute, second)
Custom datetime format
- 'a': Specify an AM/PM marker for the 12-hour time format
- 'm': Specify a minute in an hour as 'mm'.
- 's': Specify a second in a minute as 'ss'.
- 'S': Specify a millisecond as 'SSS'.
- 'z': Specify a timezone, such as 'Pacific Standard Time' and 'Indian Standard Time'.
- 'Z': Specify an offset time for a timezone, such as '+0550' for 'Indian Standard Time'
- 'h' or 'H': Specify an hour as 'hh' or 'HH'.
- F or FF: Specify day of the week in a month with or without leading zero. For example, yyyy-ww-F or yyyy-ww-0F.
- 'd': Specify a day as 'd' or 'dd'.
- 'D': Specify a day in a year as 'D' or 'DD'.
- 'E': Specify day of the week as 'EEE' (Sun-Sat) or 'EEEE' (Sunday-Saturday).
- 'M': Specify a month as 'M', 'MM', 'MMM' (abbreviated name of the month, for example, Jan, Feb), or 'MMMM' (full name of the month, for example, January, February).
- 'y' and 'Y': Specify a year as 'yy' or 'yyyy' and specify the year of the week as 'YY' respectively.
Format | Sample output |
yyyy-MM-dd | 2018-09-30 |
yyyy-M-d | 2020-9-8 |
dd-MM-yyyy | 25-12-2018 |
yyyy-MM-dd HH:mm:ss | 2018-12-25 23:50:55 |
hh:mm:ss.SSS a | 10:15:35.889 AM / 10:15:35.889 PM |
yyyy-MM-dd HH:mm:ss.SSS | 2018-12-25 23:50:55.999 |
yyyy-MM-dd HH:mm:ss.SSS Z | 2018-12-25 23:50:55.999 +0530 |
D:dd-mm-yyyy | 130:09-06-2024 |
h.mm a | 4.10 PM |
D 'days', yyyy | 365 days, 2019 |
Follow us