All Products
Search
Document Center

DataWorks:Typical scenarios for post-processing the return values of scheduling parameters

Last Updated:Mar 26, 2026

Scheduling parameters return standard time strings by default, which don't always fit complex business needs — such as getting the last day of a previous month, identifying a quarter, or building time ranges for incremental sync. This page shows how to transform those return values into the exact formats your tasks require.

All examples assume the task instance's scheduled time (CYCTIME) is 20250727000500.

Choose an approach

Two approaches are available depending on whether the target node supports inline function calls.

Approach How it works Use when
Direct processing Call engine functions directly inside the node's code The node supports function computation (e.g., ODPS SQL nodes)
Pre-processing with an assignment node An upstream assignment node transforms the value and passes it as a context parameter The node cannot evaluate functions in its code (e.g., some offline sync nodes)
Use an assignment node only when the target node cannot process functions inline. If the target node supports engine functions, use direct processing — it is simpler and requires no additional upstream dependency.

Scheduling parameter format reference

The table below shows the format specifiers and their output for the example CYCTIME value 20250727000500.

Parameter syntax Output Description
$[yyyy-mm] 2025-07 Year and month with separator
$[yyyymmdd] 20250727 Current date
$[yyyymmdd-1] 20250726 Previous day
$[yyyymmddhh24] 2025072700 Date and hour
$[yyyymmddhh24-1/24] 2025072623 One hour before
$[yyyymmddhh24miss] 20250727000500 Full timestamp
$[mm] 07 Month only
$[hh24-15/24/60] 23 Hour, 15 minutes before
$[mi-15/24/60] 50 Minute, 15 minutes before
$[yyyymmdd-15/24/60] 20250726 Date, 15 minutes before

Functions used in this page

Function Purpose Example
DATEADD(date, delta, unit) Add or subtract a time interval DATEADD(date'2025-07-01', -1, 'dd')2025-06-30
REPLACE(str, from, to) Remove or replace a substring REPLACE('2025-06-30', '-', '')20250630
CEIL(value) Round up to the nearest integer CEIL(7/3)3
CAST(value AS type) Cast a value to a different type CAST('07' AS INT)7
unix_timestamp(str, fmt) Convert a formatted datetime string to a UNIX timestamp

Scenario 1: Process return values directly in an SQL node

ODPS SQL nodes support MaxCompute SQL functions inline. The examples below show common time transformation patterns. For other SQL node types, check which functions are available in the target engine.

Get the last day of the previous month

Use this to partition or settle monthly data using the last day of the previous month in yyyymmdd format.

Parameter configuration:

last_month=$[yyyy-mm]

SQL logic:

Construct the first day of the current month from the last_month parameter, subtract one day with DATEADD, then strip the separators with REPLACE.

SELECT REPLACE(DATEADD(date'${last_month}-01', -1, 'dd'), '-', '');

Result: last_month resolves to 2025-07. After processing, the output is 20250630.

Get the current quarter

Calculate which quarter (1–4) the scheduled time falls in, based on the month.

Parameter configuration:

month=$[mm]

SQL logic:

Divide the month by 3 and round up.

SELECT CEIL(CAST('${month}' AS INT) / 3);

Result: month resolves to 07. After processing, the output is 3.

Get time components 15 minutes before the scheduled time

Use offset expressions directly in the parameter syntax to shift the scheduled time backward by 15 minutes.

Parameter configuration:

year=$[yyyy-15/24/60]
month=$[yyyymm-15/24/60]
day=$[yyyymmdd-15/24/60]
hour=$[hh24-15/24/60]
mi=$[mi-15/24/60]

SQL logic:

Reference the parameters directly — no additional functions needed.

SELECT 'year=${year} month=${month} day=${day} hour=${hour} mi=${mi}';

Result: After the cross-day offset, the output is year=2025 month=202507 day=20250726 hour=23 mi=50.

Scenario 2: Generate time ranges for incremental sync

Batch sync tasks often need a left-open, right-closed time range in yyyymmddhh24miss format. The examples below cover daily and hourly scheduling intervals.

Daily scheduling interval

Capture all events from 00:00:00 yesterday through 00:00:00 today.

Parameter configuration:

beginDateTime=$[yyyymmdd-1]
endDateTime=$[yyyymmdd]

SQL logic:

Append 000000 (zero hour, minute, and second) to each date parameter in the WHERE clause.

event_time > '${beginDateTime}000000' AND event_time <= '${endDateTime}000000'

Result: beginDateTime = 20250726000000, endDateTime = 20250727000000.

Hourly scheduling interval

Capture all events from the start of the previous hour through the start of the current hour.

Parameter configuration:

beginDateTime=$[yyyymmddhh24-1/24]
endDateTime=$[yyyymmddhh24]

SQL logic:

Append 0000 (zero minute and second) to each parameter.

event_time >= '${beginDateTime}0000' AND event_time < '${endDateTime}0000'

Result: beginDateTime = 20250726230000, endDateTime = 20250727000000.

Scenario 3: Pre-process parameters using an assignment node

When a target node — such as some offline sync nodes — cannot evaluate functions in its code, use an upstream assignment node to transform the value first, then pass the result downstream as a context parameter.

The following example converts a standard scheduling parameter to a UNIX timestamp for an incremental sync task that uses a timestamp field as its filter.

  1. Create an assignment node upstream of the sync node.

  2. In the assignment node, use an engine function, such as unix_timestamp, to convert a standard scheduling parameter, for example, $[yyyymmddhh24miss], into a UNIX timestamp format.

  3. Configure the assignment node's output as an input context parameter for the downstream offline sync node. For setup details, see Configure and use node context parameters.