You need to enable JavaScript to run this app.
Torch Log Service

Torch Log Service

Copy page
Download PDF
Timed SQL Analysis
SQL time window syntax
Copy page
Download PDF
SQL time window syntax
When creating a scheduled SQL task, you need to specify the SQL time window in the SQL analysis rule configuration, which defines the time range for query and analysis of logs. The SQL time window must follow specific syntax rules. This topic describes these rules and provides examples of expressions for common scenarios.​
Syntax format​
The SQL time window syntax supports the following formats:​
​
Format​
Description​
@{unit}​
Round down from the original time.​
For example, @h means rounding time to the nearest hour. If the original time is 01:23:17, it becomes 01:00:00 after rounding.​
+{num}{unit}​
Add the specified time interval to the original time.​
For example, +3h means postpone by 3 hours.​
-{num}{unit}​
Subtract the specified time interval from the original time.​
For example, -30s means 30 seconds earlier.​
​
The parameters are described below:​
​
Parameters​
Description​
{num}​
Positive integer. Optional. If omitted, the default value is 1. For example, if the time expression is -h, it means subtracting 1 hour.​
{unit}​
Time unit, such as s (seconds), m (minutes), h (hours), d (days), M (months).​
​
Time units​
The SQL time window expression supports the following time units:​
​
Time units​
Description​
M​
Month​
d​
Day​
h​
Hour​
m​
Minute​
s​
Second​
​
Expression examples​
SQL time window expressions for common scenarios are shown as below:​
​
Start time​
End time​
Description​
@m-15m​
@m​
The previous 15 minutes.​
If the schedule starts at 10:00 and runs every 15 minutes, with an SQL time window of [@m-15m, @m) and an execution delay of 30 seconds, the instance will be scheduled at 10:00:00 and executed at 10:00:30. Data from the period [09:45~10:00) will be analyzed.​
@h-3h​
@h​
The past 3 hours.​
If: the scheduling start time is 10:00; scheduling interval is 3 hours; SQL time window is set to [@h-3h,@h); execution delay is 30 seconds; then: the instance scheduling time is 10:00:00; execution time is 10:00:30; and the data for the period [07:00~10:00) will be analyzed.​
@h-12h-30m​
@h​
The past 12 hours and 30 minutes.​
If: the scheduling start time is 22:30:00; scheduling interval is 12.5 hours (750 minutes); SQL time window is set to [@h-12-30m,@h); execution delay is 30 seconds; then: the instance scheduling time is 22:30:30; execution time is 22:30:30; and the data for the period [10:00~22:30) will be analyzed.​
​
​
Last updated: 2026.03.16 16:34:35