[Tips & Tricks] Getting a specific date with “Date acquisition” operation

There are many methods to retrieve a date in MICHIRU RPA. By using the following formula in “Date acquisition” operation, you can get a specific date such as today, yesterday, and the last date of the month. The following are examples of what you can get

Get the date of todayDate
Get the current date and time Now
Get the current timeTime
Add to or subtract from dateCalculate with date to get the date you want.
DateAdd (unit to add/subtract, value to add/subtract, base date)
Get weekdayWeekdayName

Please don’t forget to create data save destination to store the retrieved date and time data.

Getting date and time of the current day

Input “Date” to get the date of today, and “Now” to get the current date and time.

Today’s date
  • Select “Function / Script” > “Date acquisition” from the the operation menu.
  • Input “Date” in the “Tgt date” field.
  • Select the date format you would like to use from the “Format” drop-down menu.
  • Select the data destination to store the data by clicking the button at the end of the “Result” field.

The retrieved data will be stored in the “Today_Date” data save destination after the execution.

Current date and time
  • Select “Function / Script” > “Date acquisition” from the the operation menu.
  • Input “Now” in the “Tgt date” field.
  • Select “Direct config” from the “Format” drop-down menu.
  • Input “yyyy-mm-dd hh:mm:ss” in the “Formula” field.
  • Select the data destination to store the data by clicking the button at the end of the “Result” field.

The retrieved data will be stored in the “Current_Time” data save destination after the execution.

Getting date and time of the day before/after

You can do calculation with formula to get the date the you want. One of the simplest ways is to use “Date ± the days you want to add/subtract”. Another way is to use “DateAdd(unit to add/subtract, value to add/subtract, base date)” formula for more customized result.

For the “Date” method, the calculation will be made with today as the base date. If today is the 10th of a month, “+1” will result in the “11” for the day, while “-2” will return “8”.

With the “DateAdd” method, you can perform more varied calculation to get the result in the unit of your choice. Set the parameters in parentheses as follows.

Unit to add/subtractWhen adding/subtracting year: “yyyy”
When adding/subtracting month: “m”
When adding/subtracting day: “d”
Value to add/subtract“-” to get a point of time before, “+” to get a point of time after the base date.
Base dateSpecify the base date to use for the calculation.
When using today’s date for calculation: “Date”
When using a specific date for calculation: “2024/01/01”
Parameters for DateAdd

Here are the examples of DateAdd Usage.

3 years after todayDateAdd(“yyyy”,3 ,Date)
4 months before todayDateAdd(“m”,-4,Date)
30 days after 15 January 2024DateAdd(“d”,30,”2024/01/15″)
Examples of DateAdd Usage
Yesterday’s date
  • Select “Function / Script” > “Date acquisition” from the the operation menu.
  • Input “DateAdd(“d”,-1,Date)” in the “Tgt date” field.
  • Select the date format you would like to use from the “Format” drop-down menu.
  • Select the data destination to store the data by clicking the button at the end of the “Result” field.

The retrieved data will be stored in the “Yesterday_Date” data save destination after the execution.

Tomorrow’s date
  • Select “Function / Script” > “Date acquisition” from the the operation menu.
  • Input “Date + 1” in the “Tgt date” field.
  • Select the date format you would like to use from the “Format” drop-down menu.
  • Select the data destination to store the data by clicking the button at the end of the “Result” field.

The retrieved data will be stored in the “Tomorrow_Date” data save destination after the execution.

Getting the first day of a month

  • Select “Function / Script” > “Date acquisition” from the the operation menu.
  • Input “Date” in the “Tgt date” field.
  • Select “Direct config” from the “Format” drop-down menu.
  • Input “yyyy/mm/01” in the “Formula” field.
  • Select the data destination to store the data by clicking the button at the end of the “Result” field.

The retrieved data will be stored in the “1st_DayofMonth” data save destination after the execution.

Getting the last day of a month

Since the last day of a month changes depending on the month, the calculation is made using the first day of the following month.

Example: Last day of the current month → Going back 1 day from the 1st day of the following month.
Last day of the previous month → Going back 1 day from the 1st day of the current month.
Last day of the following month → Going back 1 day from the 1st day of the month after the following month.

Last day of the current month

Start by getting the first day of the following month.

  1. Select “Function / Script” > “Date acquisition” from the the operation menu.
  2. Input “DateAdd(“m”,1,Date)” in the “Tgt date” field.
  3. Select “Direct config” from the “Format” drop-down menu.
  4. Input “yyyy/mm/01” in the “Formula” field.
  5. Select the data destination to store the data by clicking the button at the end of the “Result” field. The retrieved data will be stored in the “1stDay_FollowingMonth” data save destination after the execution.

Next, create another operation to get the last day of the current month by subtracting a day from the 1st day of the following month.

  1. Select “Function / Script” > “Date acquisition” from the the operation menu.
  2. Input “DateAdd(“d”,-1,[@1stDay_FollowingMonth])” in the “Tgt date” field.
  3. Select the date format you would like to use from the “Format” drop-down menu.
  4. Select the data destination to store the data by clicking the button at the end of the “Result” field.

The retrieved data will be stored in the “LastDay_CurrentMonth” data save destination after the execution.

Last day of the previous month

Start by getting the first day of the current month.

  1. Select “Function / Script” > “Date acquisition” from the the operation menu.
  2. Input “Date” in the “Tgt date” field.
  3. Select “Direct config” from the “Format” drop-down menu.
  4. Input “yyyy/mm/01” in the “Formula” field.
  5. Select the data destination to store the data by clicking the button at the end of the “Result” field. The retrieved data will be stored in the “1stDay_CurrentMonth” data save destination after the execution.

Next, create another operation to get the last day of the previous month by subtracting a day from the 1st day of the current month.

  1. Select “Function / Script” > “Date acquisition” from the the operation menu.
  2. Input “DateAdd(“d”,-1,[@1stDay_CurrentMonth])” in the “Tgt date” field.
  3. Select the date format you would like to use from the “Format” drop-down menu.
  4. Select the data destination to store the data by clicking the button at the end of the “Result” field.

The retrieved data will be stored in the “LastDay_PreviousMonth” data save destination after the execution.

Last day of the following month

Start by getting the first day of the month after the following month.

  1. Select “Function / Script” > “Date acquisition” from the the operation menu.
  2. Input “DateAdd(“m”,2,Date)” in the “Tgt date” field.
  3. Select “Direct config” from the “Format” drop-down menu.
  4. Input “yyyy/mm/01” in the “Formula” field.
  5. Select the data destination to store the data by clicking the button at the end of the “Result” field. The retrieved data will be stored in the “1stDay_MonthAfter” data save destination after the execution.

Next, create another operation to get the last day of the following month by subtracting a day from the 1st day of the month after the following month.

  1. Select “Function / Script” > “Date acquisition” from the the operation menu.
  2. Input “DateAdd(“d”,-1,[@1stDay_MonthAfter])” in the “Tgt date” field.
  3. Select the date format you would like to use from the “Format” drop-down menu.
  4. Select the data destination to store the data by clicking the button at the end of the “Result” field.

The retrieved data will be stored in the “LastDay_FollowingMonth” data save destination after the execution.

よかったらシェアしてね!
  • URLをコピーしました!
目次