Task Parameter Syntax Reference

This page is the complete syntax reference for task parameters, covering system built-in parameters, time expressions, and built-in time functions in detail.

System Built-in Parameters

The system provides a set of commonly used parameters that you can use directly for parameter assignment — no manual calculation needed.

Date and Time Parameters

Parameter nameFormatDescriptionExample (reference time: 2023-09-22 18:00:00)
bizdateyyyyMMddBusiness date (scheduled time minus 1 day)20230921
sys_biz_dayyyyy-MM-ddBusiness date2023-09-21
sys_biz_datetimeyyyy-MM-dd HH:mm:ssBusiness datetime2023-09-21 18:00:00
sys_plan_dayyyyy-MM-ddScheduled date2023-09-22
sys_plan_datetimeyyyy-MM-dd HH:mm:ssScheduled datetime2023-09-22 18:00:00
sys_plan_timestamp13-digit timestampScheduled timestamp (milliseconds)1695463200000

Task Information Parameters

Parameter nameDescriptionExampleNotes
sys_task_idTask ID1002Scheduled run only
sys_task_nameTask namedemo_taskScheduled run only
sys_task_ownerTask ownerUAT_TESTScheduled run only

Usage Examples

-- Filter partitions by business date SELECT * FROM table WHERE dt = '${dt}'; -- Parameter config: dt = sys_biz_day -- Scheduled time 2023-09-22, actual execution: WHERE dt = '2023-09-21' -- Use the scheduled timestamp SELECT * FROM table WHERE create_time >= ${start_ts}; -- Parameter config: start_ts = sys_plan_timestamp -- Result: WHERE create_time >= 1695463200000

Usage Recommendations

  • Business date scenarios: prefer bizdate or sys_biz_day
  • When hours, minutes, and seconds are needed: use sys_biz_datetime or sys_plan_datetime
  • Timestamp calculations: use sys_plan_timestamp
  • Audit logging: use the sys_task_* parameters to record task information

Time Expressions

Time expressions support flexible time formatting and offset calculations and are the core feature of the parameter system.

Basic Syntax

$[time_format] # Basic formatting $[time_format, offset] # With offset $[time_format, offset1, offset2, ...] # Multiple offsets (applied in sequence)

Time Format Elements

Time expressions follow the ISO-8601 standard and are strictly case-sensitive.

ElementMeaningExample
yyyyFour-digit year2023
yyTwo-digit year23
MMTwo-digit month (01-12)09
ddTwo-digit day (01-31)22
HH24-hour hour (00-23)18
mmMinute (00-59)59
ssSecond (00-59)49
.SSSMillisecond0.377
ZZTime zone+08:00

Common Format Combinations

$[yyyy-MM-dd] → 2023-09-22 $[yyyyMMdd] → 20230922 $[yyyy/MM/dd] → 2023/09/22 $[yyyy-MM-dd HH:mm:ss] → 2023-09-22 18:00:00 $[yyyyMMddHHmmss] → 20230922180000 $[HH:mm:ss] → 18:00:00 $[yyyy-MM-dd HH:mm:ss.SSSZZ] → 2023-09-22 18:00:00.377+08:00

Time Offsets

UnitAbbreviationFull nameExample
Millisecondmsmilli/millisecond400ms
Secondssec/second30s
Minutemmin/minute15m
Hourhhour2h
Daydday-1d
Weekwweek-1w
Monthmonmonth-1mon
Yearyyear-1y

Offset Examples

$[yyyy-MM-dd, -1d] → Yesterday $[yyyy-MM-dd, 1d] → Tomorrow $[yyyy-MM-dd, -1mon] → Same day last month $[yyyy-MM-dd, -1y] → Same day last year $[HH:mm:ss, -1h] → 1 hour ago -- Multiple offsets (applied in sequence) $[yyyy-MM-dd, -1y, -1mon, -1d] → Last year, last month, yesterday $[yyyyMMdd, 1mon, -7d] → Next month minus 7 days


Built-in Time Functions

These handle calculation scenarios that time expressions cannot express directly, such as "first day of this month" or "last Sunday."

Month Functions

first_day_of_month() — First day of the current month

first_day_of_month() # Default format yyyy-MM-dd first_day_of_month(format) # Specify format first_day_of_month(format, duration) # With offset

-- First day of the current month month_start = first_day_of_month() → 2023-09-01 -- First day of last month last_month_start = first_day_of_month('yyyy-MM-dd', '-1mon') → 2023-08-01 -- Custom format month_start = first_day_of_month('yyyyMMdd') → 20230901

last_day_of_month() — Last day of the current month

last_day_of_month() # Default format yyyy-MM-dd last_day_of_month(format) # Specify format last_day_of_month(format, duration) # With offset

-- Last day of the current month month_end = last_day_of_month() → 2023-09-30 -- Last day of last month last_month_end = last_day_of_month('yyyy-MM-dd', '-1mon') → 2023-08-31

Week Functions

first_day_of_week() — First day of the current week (Monday)

first_day_of_week() # Default format yyyy-MM-dd first_day_of_week(format) # Specify format first_day_of_week(format, duration) # With offset

-- This Monday (assuming current date is 2023-09-22, Friday) week_start = first_day_of_week() → 2023-09-18 -- Last Monday last_week_start = first_day_of_week('yyyy-MM-dd', '-1w') → 2023-09-11

last_day_of_week() — Last day of the current week (Sunday)

last_day_of_week() # Default format yyyy-MM-dd last_day_of_week(format) # Specify format last_day_of_week(format, duration) # With offset

-- This Sunday week_end = last_day_of_week() → 2023-09-24 -- Last Sunday last_week_end = last_day_of_week('yyyy-MM-dd', '-1w') → 2023-09-17

day_of_week() — Returns the day of the week

day_of_week() # Today's day of the week (returns 1-7, 1=Monday, 7=Sunday) day_of_week(duration) # Day of the week after offset

weekday = day_of_week() → 5 (Friday) weekday = day_of_week('-1d') → 4 (yesterday was Thursday)

get_day_of_week() — Get the date of a specific day of the week

get_day_of_week(format, whichDay) # That day of the current week (1=Monday, 7=Sunday) get_day_of_week(format, whichDay, duration) # That day of the offset week

-- This Tuesday (assuming current date is 2023-09-22, Friday) this_tuesday = get_day_of_week('yyyy-MM-dd', 2) → 2023-09-19 -- Last Wednesday last_wednesday = get_day_of_week('yyyy-MM-dd', 3, '-1w') → 2023-09-13 -- Next Friday next_friday = get_day_of_week('yyyy-MM-dd', 5, '1w') → 2023-09-29

week_of_month() — Week number within the current month

week_of_month() # Which week of the month today falls in (returns integer) week_of_month(duration) # Which week of the month after offset

week_of_year() — Week number within the current year

week_of_year() # Which week of the year today falls in (returns integer) week_of_year(duration) # Which week of the year after offset

Timestamp Functions

timestamp() — Millisecond timestamp

timestamp() # Millisecond timestamp of the current scheduled time (13 digits) timestamp(offset1, offset2, ...) # With offsets

current_ts = timestamp() → 1695463200000 (2023-09-22 18:00:00) yesterday_ts = timestamp(-1d) → 1695376800000

biz_timestamp() — Business timestamp (based on 00:00:00)

biz_timestamp() # Millisecond timestamp of today at 00:00:00 (13 digits) biz_timestamp(offset1, offset2, ...) # With offsets

today_start = biz_timestamp() → 1695312000000 (2023-09-22 00:00:00) yesterday_start = biz_timestamp(-1d) → 1695225600000


Quick Reference

Common Time Requirements

RequirementParameter configurationExample result (reference: 2023-09-22)
Today$[yyyy-MM-dd] or sys_plan_day2023-09-22
Yesterday$[yyyy-MM-dd, -1d] or sys_biz_day2023-09-21
Same day last week$[yyyy-MM-dd, -7d]2023-09-15
Same day last month$[yyyy-MM-dd, -1mon]2023-08-22
First day of this monthfirst_day_of_month()2023-09-01
Last day of this monthlast_day_of_month()2023-09-30
First day of last monthfirst_day_of_month('yyyy-MM-dd', '-1mon')2023-08-01
Last day of last monthlast_day_of_month('yyyy-MM-dd', '-1mon')2023-08-31
This Mondayfirst_day_of_week()2023-09-18
This Sundaylast_day_of_week()2023-09-24
Last Mondayfirst_day_of_week('yyyy-MM-dd', '-1w')2023-09-11
Last Sundaylast_day_of_week('yyyy-MM-dd', '-1w')2023-09-17
This Tuesdayget_day_of_week('yyyy-MM-dd', 2)2023-09-19
Last year yesterday$[yyyy-MM-dd, -1y, -1d]2022-09-21
Today at 00:00 timestampbiz_timestamp()1695312000000
Current timestamptimestamp()1695463200000

Time Function Quick Reference

FunctionPurposeReturn type
first_day_of_month()First day of the current monthDate string
last_day_of_month()Last day of the current monthDate string
first_day_of_week()First day of the current week (Monday)Date string
last_day_of_week()Last day of the current week (Sunday)Date string
day_of_week()Day of the week (1-7)Integer
week_of_month()Week number within the current monthInteger
week_of_year()Week number within the current yearInteger
get_day_of_week()Date of a specific day of the weekDate string
timestamp()Millisecond timestamp (based on scheduled time)13-digit integer
biz_timestamp()Millisecond timestamp (based on 00:00:00)13-digit integer
unix_timestamp()Second timestamp10-digit integer
biz_unix_timestamp()Business second timestamp10-digit integer
biz_format()Business time formattingString