DataWorks provides two families of scheduling parameters for injecting dynamic time values into partition names, filenames, and SQL queries: ${...} based on the business date and $[...] based on the scheduled time. This topic compares their formats, precision, and offset capabilities to help you choose the right one.
For the base time definitions and transformation rules, see Supported formats for scheduling parameters.
Parameter formats at a glance
The following table shows all six built-in parameter formats. Assume the current time is November 01, 2025 and a task runs daily at 00:00. The parameter is referenced in code as pt=${datetime}.
| Parameter format | Description | Example assignment | Resolved value |
|---|---|---|---|
${yyyymmdd} |
Business date (T-1), accurate to the day. Use for date-partitioned daily batch jobs — no manual offset needed. | datetime=${yyyymmdd} |
datetime=20251031 |
$[yyyymmddhh24miss] |
Scheduled trigger time, accurate to the second. Use when you need sub-day precision. | datetime=$[yyyymmddhh24miss] |
datetime=20251101000000 |
$bizdate |
Gets the business time. Equivalent to ${yyyymmdd}. |
datetime=$bizdate |
datetime=20251031 |
$cyctime |
Gets the scheduled time, accurate to the second. Equivalent to $[yyyymmddhh24miss]. |
datetime=$cyctime |
datetime=20251101000000 |
$gmtdate |
Gets the current time, accurate to the day. | datetime=$gmtdate |
datetime=20251101 |
$bizmonth |
Business month. Returns the previous month if business time and current time fall in the same month; otherwise returns the month of the business time. | datetime=$bizmonth |
datetime=202510 (see note below) |
$bizmonth example — if the current time is November 01, 2025:
-
Business time =
November 02, 2025(same month as current time) →datetime=202510 -
Business time =
October 31, 2025(different month from current time) →datetime=202510
Core differences between ${...} and $[...]
${...} (business date) |
$[...] (scheduled time) |
|
|---|---|---|
| Time baseline | Business date (T-1) | Scheduled trigger time (T) |
| Time precision | Day (year, month, day) | Second (year, month, day, hour, minute, second) |
| Offset support | Years, months, weeks, days | Days, hours, minutes |
| Limitations | Cannot express hours, minutes, or seconds | No direct year or month offset syntax ($[yyyy±N], $[mm±N]). Use add_months instead. |
| Shorthand equivalent | ${yyyymmdd} = $bizdate |
$[yyyymmddhh24miss] = $cyctime |
When to use which
-
Use
${...}for day-level date partitions in daily batch jobs — it automatically reflects the previous day's data date (T-1) without manual offset. -
Use
$[...]when you need hour-level or minute-level precision, or when calculating month or year offsets (useadd_months). -
Use
$bizdateor$cyctimeas shorthand when the format matches exactly. -
Use
$gmtdatewhen you need the current time accurate to the day.
For full usage details, see Supported formats for scheduling parameters and Configure and use scheduling parameters.
Usage examples
The following examples use an ODPS SQL node. The scheduled time is 10:30:00 on July 20, 2025.
| Target value | ${...} |
$[...] |
|---|---|---|
Year: 2025 |
datetime=${yyyy} → pt=2025 |
datetime=$[yyyy] → pt=2025 |
Short year: 25 |
datetime=${yy} → pt=25 |
datetime=$[yy] → pt=25 |
Previous year: 2024 |
datetime=${yyyy-1} → pt=2024 |
datetime=$[add_months(yyyymmdd,-12)] → pt=2024 |
Month: 07 |
datetime=${mm} → pt=07 |
datetime=$[mm] → pt=07 |
Day: 20 |
datetime=${dd} → pt=20 |
datetime=$[dd] → pt=20 |
Date one month earlier: 2025-06-20 |
datetime=${yyyy-mm-dd-29} → pt=2025-06-20 Not recommended — you must account for the varying number of days in each month. Use $[...] instead. |
datetime=$[add_months(yyyymmdd,-1)] → pt=2025-06-20 |
Previous day: 2025-07-19 |
datetime=${yyyy-mm-dd} → pt=2025-07-19 |
datetime=$[yyyy-mm-dd-1] → pt=2025-07-19 |
Same date one year earlier: 2024-07-20 |
datetime=${yyyy-mm-dd-364} → pt=2024-07-20 Not recommended — you must account for leap years. Use $[...] instead. |
datetime=$[add_months(yyyymmdd,-12)] → pt=2024-07-20 |
Time only: 10:30:00 |
Not supported | datetime=$[hh24:mi:ss] → pt=10:30:00 |
Full datetime: 2025-07-20 10:30:00 |
Not supported | Define two parameters separated by a space: datetime1=$[yyyy-mm-dd] datetime2=$[hh24:mi:ss]; code reference: pt=${datetime1} ${datetime2} → pt=2025-07-20 10:30:00 |
One minute earlier: 2025-07-20 10:29:00 |
Not supported | datetime1=$[yyyy-mm-dd] datetime2=$[hh24:mi:ss-1/24/60] → pt=2025-07-20 10:29:00 |
One hour earlier: 2025-07-20 09:30:00 |
Not supported | datetime1=$[yyyy-mm-dd] datetime2=$[hh24:mi:ss-1/24] → pt=2025-07-20 09:30:00 |
Previous day datetime (no space): 2025071910:30:00 |
Not supported | datetime=$[yyyymmddhh24miss-1] → pt=2025071910:30:00 |
Previous day datetime (with space): 20250719 10:30:00 |
Not supported | Parameter expressions do not support spaces. Define two parameters: datetime1=$[yyyymmdd-1] datetime2=$[hh24:mi:ss]; code reference: pt=${datetime1} ${datetime2} → pt=20250719 10:30:00 |
What's next
-
Supported formats for scheduling parameters — complete syntax reference for
${...}and$[...] -
Configure and use scheduling parameters — step-by-step configuration guide