Skip to main content

SF-0401 · Concept · Medium

Can you explain or elaborate all the special characters used in CORN_EXP?

✓ Verified by Vikas Singhal · Last reviewed 5/17/2026 · Updated for Spring '26

Salesforce cron expressions use eight special characters: , - * ? / L W #. Each carries a specific meaning and is only valid in certain fields.

The full list

CharacterMeaningWhere allowed
,List separator: multiple distinct valuesAll fields
-Range: contiguous span of valuesAll fields
*Any valueAll fields
?No specific value (skip this field)Day-of-Month, Day-of-Week only
/Step: every Nth value starting from XAll fields
LLast (last day of month, or last weekday-of-month)Day-of-Month, Day-of-Week only
WWeekday: closest weekday to the given dateDay-of-Month only
#Nth weekday of the monthDay-of-Week only

In detail

, (comma) — list

Fires on each value in the comma-separated list.

0 0 8,12,17 * * ?   →  8 AM, 12 PM, 5 PM every day
0 0 9 ? * MON,WED,FRI  →  9 AM on Mon, Wed, Fri

- (hyphen) — range

Inclusive range of values.

0 0 9-17 * * ?   →  Every hour from 9 AM through 5 PM
0 0 12 ? * MON-FRI   →  Noon Monday through Friday

* (asterisk) — any

Wildcard, matches any value in the field.

0 0 * * * ?   →  Every hour (any hour value matches)
0 */30 * * * ?   →  Every 30 minutes (any minute matching a 30-step)

? (question mark) — no specific value

Required in either Day-of-Month or Day-of-Week — never both, never neither. Means “ignore this field.”

0 0 2 * * ?   →  2 AM daily (day-of-week ignored)
0 0 2 ? * MON   →  2 AM Mondays (day-of-month ignored)

/ (slash) — step

X/Y means “starting at X, every Y units.” */Y means “every Y units.”

0 */15 * * * ?   →  Every 15 minutes (0, 15, 30, 45)
0 0 0/4 * * ?   →  Every 4 hours starting at midnight (0, 4, 8, 12, 16, 20)
0 0 9-17/2 * * ?   →  9 AM, 11 AM, 1 PM, 3 PM, 5 PM

L (last)

In Day-of-Month: last day of the month (handles 28, 29, 30, 31 correctly).

0 0 0 L * ?   →  Midnight on the last day of every month

In Day-of-Week: last weekday-of-month.

0 0 0 ? * 6L   →  Midnight last Friday of each month
0 0 0 ? * 1L   →  Midnight last Sunday of each month

W (weekday)

Day-of-Month only. Means “closest weekday to” the given date.

0 0 9 15W * ?   →  9 AM on the weekday closest to the 15th of each month
                   (Sat 15 → Fri 14, Sun 15 → Mon 16)

# (Nth weekday)

Day-of-Week only. Format: dayNumber#nthOccurrence.

0 0 9 ? * 2#1   →  9 AM the first Monday of each month
0 0 9 ? * 5#3   →  9 AM the third Thursday

Day-of-Week numbering: 1 = Sunday, 2 = Monday, … 7 = Saturday. Or use abbreviations: SUN, MON, … SAT.

Combining special characters

Cron lets you mix special characters within a single field:

0 0 0/4,12 * * ?   →  Every 4 hours plus also at noon (uncommon but valid)
0 0,30 9-17 ? * MON-FRI   →  Every half hour, 9 AM to 5 PM, weekdays

Common interview follow-ups

  • Why the ? requirement? — Day-of-Month and Day-of-Week could conflict (e.g., “Mondays” vs “the 15th”). Salesforce makes you pick which to use.
  • What does L mean by itself in Day-of-Week? — Last day-of-week of the month (Saturday by default? Actually it means just “last day-of-week”, typically use 7L).
  • Is H (hash) supported like in Jenkins cron? — No — that’s a Jenkins extension, not standard cron.

Verified against: Apex Developer Guide — Cron Expressions. Last reviewed 2026-05-17.