Task Object Properties
The task object provides access to task-level runtime information in expressions. These properties are available within pipelines executed by tasks and provide timing information about task execution.
Supported Task Types:
- Scheduled Task
- Triggered Task
- Ultra Pipeline Task
task.start
Description:
The start time for a Scheduled Task, Triggered Task, and Ultra Pipeline Task. You enter this expression in the Expression field of a Snap. If you manually initiate the Task in Designer, then the task.start result is the starting time of the Pipeline, and the task.end result is an arbitrary date far in the future (for example, 2999-12-31:11:59).
Syntax:
task.start
Returns: DateTime object representing the task start time
Example:
task.start
// Returns: "2019-11-09T11:00:00"
task.end
Description:
The end time and date for a Scheduled Task. You enter this expression in the Expression field of a Snap, and the result is displayed on the Extra Details tab of the Pipeline Execution Statistics window.
Syntax:
task.end
Returns: DateTime object representing the task end time
Example:
task.end
// Returns: "2019-11-09T12:00:00"
Task Properties with Scheduled Tasks
For Scheduled Tasks, the task.start property should indicate when the Scheduled Task previously started. If the Scheduled Task has never been executed before, then the task.start is equivalent to the date and time when it currently starts.
Example: Task Running Every Minute
If a Task runs every minute and starts today at noon, then expect the following values:
| Scheduled Task Execution | task.start | task.end |
|---|---|---|
| 2021-04-16 12:00:00 | 2021-04-16 12:00:00 | 2021-04-16 12:00:00 |
| 2021-04-16 12:01:00 | 2021-04-16 12:00:00 | 2021-04-16 12:01:00 |
| 2021-04-16 12:02:00 | 2021-04-16 12:01:00 | 2021-04-16 12:02:00 |
Task Properties with Ultra Pipeline and Triggered Tasks
For Triggered Tasks and Tasks created from Ultra Pipelines, this expression generates a result, but the end date is always some future date, since with both of these Task types the end date is undefinable. The start time is the same as that of the pipe.startTime function.
pipe.startTime instead of task.start for more reliable timing information.Common Use Cases
Processing Data Since Last Execution:
// Query data modified since last task execution
{
"query": "SELECT * FROM data WHERE modified_date >= ?",
"parameters": [task.start]
}
Time Window for Data Processing:
// Process data within the task execution window
{
"startDate": task.start,
"endDate": task.end,
"duration": task.end.getTime() - task.start.getTime()
}
Incremental Data Loading:
// Load data incrementally based on task schedule
{
"filter": {
"created_at": {
"$gte": task.start,
"$lt": task.end
}
}
}
Audit Logging:
// Log task execution details
{
"taskExecution": {
"startTime": task.start,
"endTime": task.end,
"recordsProcessed": snap.out.totalCount,
"status": "completed"
}
}
File Naming with Task Time:
// Generate filename with task execution time
"data_export_" +
task.start.toLocaleDateString({"format":"yyyyMMdd_HHmmss"}) +
".csv"
Calculating Processing Duration:
// Calculate expected processing window
{
"window": {
"start": task.start.toString(),
"end": task.end.toString(),
"durationMinutes": (task.end.getTime() - task.start.getTime()) / 60000
}
}
Handling Manual Execution:
// Check if this is a scheduled or manual execution
{
"isScheduled": task.end.getFullYear() < 2900,
"startTime": task.start,
"endTime": task.end
}
Best Practices
- Scheduled Tasks: Use
task.startandtask.endto define time windows for data processing. - Incremental Processing: Leverage
task.startto track the last processed timestamp for incremental data loads. - Ultra/Triggered Tasks: Be aware that
task.endis a far future date; usepipe.startTimeinstead. - Manual Execution: Check if
task.endis a future date (year > 2900) to detect manual vs scheduled execution. - Time Zones: Consider time zone handling when using task timestamps with external systems.
- Date Formatting: Use date formatting functions to convert timestamps to required formats.
- Error Handling: Handle cases where task properties might not be available (e.g., pipeline executed directly).
Property Reference
| Property | Description | Type | Example Value |
|---|---|---|---|
task.start |
Task start time | DateTime | 2021-04-16T12:00:00 |
task.end |
Task end time (scheduled tasks only) | DateTime | 2021-04-16T12:01:00 |
Behavior by Task Type
| Task Type | task.start | task.end | Notes |
|---|---|---|---|
| Scheduled Task | Previous execution time (or current if first run) | Current execution time | Defines processing window |
| Triggered Task | Same as pipe.startTime | Far future date (2999-12-31) | Use pipe.startTime instead |
| Ultra Pipeline Task | Same as pipe.startTime | Far future date (2999-12-31) | Use pipe.startTime instead |
| Manual Execution | Current execution time | Far future date (2999-12-31) | Indicates non-scheduled run |
Integration with Date Functions
Task properties return DateTime objects that can be used with date functions:
// Format task start time
task.start.toLocaleDateString({"format":"yyyy-MM-dd"})
// Get hour of execution
task.start.getHours()
// Calculate minutes since start
(Date.now().getTime() - task.start.getTime()) / 60000
// Add duration to start time
task.start.plusHours(1)
// Compare with current time
Date.now() > task.end
Practical Scheduling Examples
Daily Batch Processing:
// Process yesterday's data
{
"startDate": task.start.toLocaleDateString({"format":"yyyy-MM-dd"}),
"endDate": task.end.toLocaleDateString({"format":"yyyy-MM-dd"}),
"source": "daily_batch"
}
Hourly Data Sync:
// Sync data from last hour
{
"syncWindow": {
"from": task.start.toISOString(),
"to": task.end.toISOString()
},
"frequency": "hourly"
}
Weekly Report Generation:
// Generate weekly report
{
"reportPeriod": {
"weekStart": task.start,
"weekEnd": task.end,
"weekNumber": task.start.getWeekOfWeekyear()
}
}
Change Data Capture (CDC):
// Capture changes since last execution
{
"query": "SELECT * FROM audit_log WHERE change_time >= @start AND change_time < @end",
"params": {
"@start": task.start,
"@end": task.end
}
}