Skip to main content
Question

Identify the second monday of every month in AA

  • March 11, 2025
  • 4 replies
  • 103 views

Forum|alt.badge.img+2

Can someone help me with the logic of how to identify the second monday of every month in AA

4 replies

Aaron.Gleason
Automation Anywhere Team
Forum|alt.badge.img+14
  • Automation Anywhere Team
  • March 11, 2025

Consider using another scripting language like JavaScript or Python to return the value.

https://stackoverflow.com/questions/12065146/javascript-date-for-the-second-monday-of-the-month

There are other date manipulation packages on the Bot Store, but I couldn’t find one that would quickly return the second Monday of a month.


Forum|alt.badge.img+8
  • Navigator | Tier 3
  • March 11, 2025

@mahalakshmi.sambandan Try this:

 

 


madhu subbegowda
Most Valuable Pathfinder
Forum|alt.badge.img+12
  • Most Valuable Pathfinder
  • March 17, 2025

Hi ​@mahalakshmi.sambandan

Logic to Identify the Second Monday of a Month

  1. Get the First Day of the Month
    • Start with the 1st day of the current month.
  2. Find the First Monday
    • Check the day of the week for the 1st day of the month.
    • If it’s a Monday, the second Monday is on the 8th.
    • Otherwise, calculate how many days until the next Monday.
  3. Calculate the Second Monday
    • Add 7 days to the first Monday's date.

Implementation in Automation Anywhere A360

Steps:

  1. Use a DateTime Action → Get the current month & year.
  2. Set Date to the First Day of the Month (YYYY-MM-01).
  3. Use a Loop to find the First Monday.
  4. Add 7 days to get the Second Monday.

Automation Anywhere A360 Bot Logic

1. Create Variables:

  • v_CurrentYear → Stores the current year (e.g., 2025).
  • v_CurrentMonth → Stores the current month (e.g., 03 for March).
  • v_FirstDayOfMonth → Stores YYYY-MM-01.
  • v_DayOfWeek → Stores the day of the week (1 = Sunday, 2 = Monday, ..., 7 = Saturday).
  • v_SecondMonday → Stores the final date of the second Monday.

2. Automation Steps

  1. Get the Current Year & Month

    • Use the DateTime: Get current date action.
    • Extract Year → Store in v_CurrentYear.
    • Extract Month → Store in v_CurrentMonth.
  2. Set the Date to the 1st of the Month

    • Use DateTime: Set
      v_FirstDayOfMonth = v_CurrentYear + "-" + v_CurrentMonth + "-01"
  3. Find the First Monday

    • Use DateTime: Get Day of Week for v_FirstDayOfMonth.
    • If v_DayOfWeek = 2 (Monday), then
      v_SecondMonday = v_FirstDayOfMonth + 7 days.
    • Else, calculate how many days to reach Monday:
      v_DaysToMonday = 9 - v_DayOfWeek
      (If the 1st is Sunday = 1, then 9 - 1 = 8, so the first Monday is on the 2nd.)
  4. Get the Second Monday

    • v_SecondMonday = v_FirstMonday + 7 days

Shreya.Kumar
Pathfinder Community Team
Forum|alt.badge.img+14
  • Pathfinder Community Team
  • March 17, 2025

@mahalakshmi.sambandan  did any of these solutions help?