Time expression syntax

更新时间:
复制 MD 格式

When you create a Scheduled SQL task, you specify an SQL time window to define which logs Simple Log Service analyzes. Time expressions set the boundaries of this window.

Operators

Time expressions support the following operators.

Operator

Description

+

Plus

-

Minus

@

Rounds a time value down to a specified time unit. For example, rounding down 01:40 to the hour results in 01:00.

The format of a time expression is ±{num}{unit} or @{unit}, where {num} is a positive integer and {unit} is a time unit.

  • If the operator is a plus (+) or minus (-) sign, the calculation unit is in the format ±{num}{unit}. In this format, {num} is optional and defaults to 1. For example, the time expression -h means to subtract 1 hour.

  • If the operator is the at symbol (@), the format for the computing unit is @{unit}.

Time units

Time expressions support the following units.

Time unit

Description

h

Hour

m

Minute

s

Second

Examples

The following examples demonstrate common time expression patterns.

Time expression

Description

-15m@m

Subtracts 15 minutes and then rounds the result down to the minute.

For example, if you create a Scheduled SQL task and set the Scheduling Interval to 00:00 every day, the Delay Task to 30 seconds, and the SQL Time Window to [-15m@m,-5m@m), the SQL task is executed at 00:00:30 to analyze data in the [23:45, 23:55) time range.

-h@h

Subtracts 1 hour and then rounds the result down to the hour.

For example, if you create a Scheduled SQL task and set the Scheduling Interval to 00:00 every day, Delay Task to 30 seconds, and the SQL Time Window to [-h@h,-5m@m), the SQL task is executed at 00:00:30 to analyze data from the [23:00, 23:55) period.

-50m@h

Subtracts 50 minutes and then rounds the result down to the hour.

For example, if you create a Scheduled SQL task and set the Scheduling Interval to 00:00 every day, the Delay Task to 30 seconds, and the SQL Time Window to [-50m@h,-5m@m), the task is executed at 00:00:30 to analyze data from the [23:00~23:55) time range.

-12h+5m

Subtracts 12 hours and then adds 5 minutes. This is equivalent to subtracting 11 hours and 55 minutes.

For example, if you create a Scheduled SQL task and configure the Scheduling Interval to 00:00 every day, the Delay Task to 30 seconds, and the SQL Time Window to [-12h+5m,-5m), the SQL task is executed at 00:00:30 to analyze data in the [12:05~23:55) time range.