Cron expression to run twice monthly using day of week with "#' - quartz-scheduler

I'm trying to figure out how to setup quartz to run twice monthly specifying the day of week using the symbol "#".
My expression:
0 0 8 ? * 6#2,6#4
My goal is to run every second and fourth Friday of every month at 8:00
The expression is valid, but it runs only at forth Friday. The second one is ignored.
How to achieve this?
Thank you.

Unfortunately, there's not way now.
If the '#' character is used, there can only be one expression in the
day-of-week field ("3#1,6#3" is not valid, since there are two
expressions).
source: http://quartz-scheduler.org/api/2.2.0/org/quartz/CronExpression.html

if fourth is working fine. You can simply separate the two out and load the job again for second friday.
if API does not provide you the solution it always comes down to your implementation and code logic.

Related

Schedule Builds not adhering to CRON in Foundry

Schedule has been set to update this table between 14th to 25th of every month Mon-Fri. Although, the build got triggered recently on 12th of August which shouldn't happen according to the specified CRON.
The culprit seems to be a limitation of the cron expression, outside of Foundry - specifically this part:
The day of a command's execution can be specified by two fields — day of month, and day of week. If both fields are restricted (i.e., aren't *), the command will be run when either field matches the current time. For example, ``30 4 1,15 * 5'' would cause a command to be run at 4:30 am on the 1st and 15th of each month, plus every Friday.
So the cron schedule 30 8 14-25 * 1-5 will run between the 14th and 25th of the month and every Monday through Friday. (See for example crontab.guru (https://crontab.guru/#30_8_14-25_*_1-5).)
The generated description for it is not accurate, unfortunately we don't have much control over it as we use a library to turn the cron expressions into human readable expressions.
Related:
https://unix.stackexchange.com/questions/602328/are-the-day-of-month-and-day-of-week-crontab-fields-mutually-exclusive
https://unix.stackexchange.com/questions/602216/when-will-an-interval-cron-execute-the-first-time-ex-3-days/602222#602222
https://blog.healthchecks.io/2022/09/schedule-cron-job-the-funky-way/

Add dynamic content to pass a parameter to get last 03 days if today is Monday in Azure Data Factory

i want to pass dynamic content to a parameter in "Execute SSIS Package" to pass
If sysdate= monday then get last 3 days
Can someone help to build the content using functions or expression
Thanks
There are 2 ways you can achieve this.
Use an IF activity to first check if today is a Monday. You can use an expression like #equals(dayOfWeek(utcnow()),1) for a Monday check.
If true, get utcNow() - 3 days using a dynamic content of #adddays(utcnow('yyyy-MM-dd'),-3). You may need to change the format to what you need.
Easier and more efficient option, just schedule your pipeline to run every Monday. Then there is no need to check anything.

Cron Expression: What exactly is the difference between ? and * in a cron expression?

It appears to me that both mean "any of the available values". What exactly in the difference between them?
* means every possible value in the field. ? means you don't care about the value. It's used when you have two fields that may contradict each other. The common example being the day of month and day of week fields. Consider, for example a cron specification for running at 10AM on the first day of every month:
0 0 10 1 * ? *
Now let's break it down:
Seconds: 0 - we want it to run on 10:00:00
Minutes: 0 - we want it to run on 10:00:00
Hours: 10 - we want it to run on 10:00:00
Day of month: 1 - we want it to run of the 1st of every month
Month: * - we want it to run on every month (e.g., January 1st, February 1st, etc.)
Day of week: ? - we don't care about the day of week. The cron should run on the 1st of every month, regardless of whether it's a Sunday, a Monday, etc.
Year: * - we want it to run on every year
From Quartz Scheduler
* ("all values") - used to select all values within a field. For example, "*" in the minute field means "every minute".
? ("no specific value") - useful when you need to specify something in
one of the two fields in which the character is allowed, but not the
other. For example, if I want my trigger to fire on a particular day
of the month (say, the 10th), but don't care what day of the week that
happens to be, I would put "10" in the day-of-month field, and "?" in
the day-of-week field. See the examples below for clarification.
The * character is used to specify all values. For example, "*" in the minute field means " every minute ".
The ? character is allowed for the day-of-month and day-of-week fields. It is used to specify 'no specific value'. This is useful when you need to specify something in one of the two fields, but not the other. See the examples below for clarification.
You can look more here:
http://docs.netkernel.org/book/view/book:mod:cron/doc:mod:cron:cronexpression
Also if you need to create a Cron expression you can use this: http://www.cronmaker.com/
* means every time. According to the position, it will be:
every second, minute, hour, day, month.
? means that it would be
chosen by other field. So ? doesn't add filter, but it
wouldn't run every time.
? is used for setting the day, as it might be a day of month or the day of week. So if you choose the day of month (like the 1-st day of month), than you put ? in the day of week, by which you show, that it would be not every day of week, but only those days which are allowed by other conditions. And vice versa, if you set day of week, you put ? in the day of month.

single icalendar rule for 1st weekday of multiple months every year?

Is it possible to specify an event to occur on the 1st weekday of multiple months every year in a single RRULE? Using January and June as a test case, my initial attempt was:
FREQ=YEARLY;BYDAY=MO,TU,WE,TH,FR;BYMONTH=1,6;BYSETPOS=1
but BYSETPOS reduces the set down to January only. I think splitting it out into multiple rrules would work, but it would greatly increase the complexity of this area of my app so I was hoping for one rrule with a yearly freq.
Thanks!
You could try:
FREQ=MONTHLY;BYDAY=MO,TU,WE,TH,FR;BYSETPOS=1;BYMONTH=<SELECTED_MONTHS_FROM_UI>
Please note the order of options is different.

Crystal Reports parameter returns a number ie 2000. How can I use a formula to count up by one

I need to have a user enter a start Year for a report that will show 10 years of stats beginning from that start year.
I have a parameter where the user inserts the year (ie 2000) as the start year, but the parameter is just recognized as a number not as part of a date or year. Which I thought was fine (I have everything I want working in the report for the first year. Now that I want to go an add a section that takes the parameter and adds one, I'm having trouble.
DateAdd seems to just work with dates and this parameter is passed as a number. I must really be missing something. Any advice would be greatly appreciated.
Try:
Year({table.dateField}) IN {?YearPrompt} TO ({?YearPrompt}+1)