Single Cron expression for alternate saturday

Can anyone help me to get Single Cron expression for alternate saturday?

Regards,
Nagaraj Naik

Hi @Nagaraj_Jatti_Naik

Please use the below Expression,
0 0 * * 6/2

Regards,
Vasanth kumar

Thanks for the reply.

But Unexpected end of expression for 0 0 * * 6/2

Regards,
Nagaraj Naik

Hi @Nagaraj_Jatti_Naik

How about this cron expression

0 0 0 ? * 6#2

Here’s an explanation of the expression:

  • 0 0 0: This sets the time to midnight (00:00:00).
  • ?: This indicates that we are not specifying a day of the month.
  • *: This means that we want the expression to match any month.
  • 6#2: This specifies the second Saturday of the month, where 6 represents Saturday and #2 represents the second occurrence of Saturday in the month.

You can play with this CRON Generated : Free Online Cron Expression Generator and Describer - FreeFormatter.com

Regards
'Gokul

1 Like

Thanks for the reply.

But I need cron expression for

2nd and 4th saturday for each month------->Cron Expression-1
And
1st, 3rd, and 5th saturday for each month------->Cron Expression-2

Regards,
Nagaraj Naik

@Nagaraj_Jatti_Naik

Check below for every alternate Saturday

0 0 0 ? * 7#2

8 can be configured at your requirement of the hours

Hope this may help you

Thanks,
Srini

Hi @Srini84

Thanks for the reply.

But I need cron expression for

2nd and 4th saturday for each month------->Cron Expression-1
And
1st, 3rd, and 5th saturday for each month------->Cron Expression-2

Regards,
Nagaraj Naik

Based on your requirement, you need two cron expression to achieve

0 0 0 ? * 7#4

0 0 0 ? * 7#2

You need 3 cron expression to do this

0 0 0 ? * 7#1

0 0 0 ? * 7#3

0 0 0 ? * 7#5

Regards
Gokul

@Nagaraj_Jatti_Naik

A single cron cannot be used for this…one way to use a single cron is to inlcude logic of checking which saturday it is in the process

you can schedule the bot to run on every saturday and in the bot check if the previous run date is atleast more than 7 days from the current date…and you can store the date in asset if the condition is satisfied

Cdate(Previousrundate) < Now.Adddays(-8)

on then side set asset and run the bot and on else side do not set and do not run the bot

cheers

1 Like

@Nagaraj_Jatti_Naik

Yes, I agree with @Gokul001

You can’t give multiple days expression in CRON expression

So that you can divide those and place in your triggers

Hope this may help you

Thanks,
Srini