Adds a named time range to an Adaptive Server.
sp_add_time_range name, startday, endday, starttime, endtime
is the name of the time range. Time range names must be 30 characters or fewer. The name cannot already exist in the systimeranges system table of the master database.
is the day of the week on which the time range begins. This must be the full weekday name for the default server language, as stored in the syslanguages system table of the master database.
is the day of the week on which the time range ends. This must be the full weekday name for the default server language, as stored in the syslanguages system table of the master database. The endday can fall either earlier or later in the week than the startday or can be the same day as the startday.
is the time of day when the time range begins. Specify the starttime in terms of a 24-hour clock, with a value between “00:00” (midnight) and “23:59” (11:59 p.m.). Use the following form:
"HH:MM"
is the time of day when the time range ends. Specify the endtime in terms of a 24-hour clock, with a value between “00:00” (midnight) and “23:59” (11:59 p.m.). Use the following form:
"HH:MM"
To create a time range that spans the entire day, specify both a start time and an end time of “00:00”.
The endtime must occur later in the day than the starttime, unless endtime is “00:00”.
Creates the business_hours time range, which is active Monday through Friday, from 9:00 a.m. to 5:00 p.m.:
sp_add_time_range business_hours, monday, Friday, "09:00", "17:00"
Creates two time ranges, before_hours and after_hours, that, together, span all non-business hours Monday through Friday. The before_hours time range covers the period from 12:00 midnight to 9:00 a.m., Monday through Friday. The after_hours time range covers the period from 6:00 p.m. through 12:00 midnight, Monday through Friday:
sp_add_time_range before_hours, Monday, Friday, "00:00", "09:00"
sp_add_time_range after_hours, Monday, Friday, "18:00", "00:00"
Creates the weekends time range, which is 12:00 midnight Saturday to 12:00 midnight Sunday:
sp_add_time_range weekends, Saturday, Sunday, "00:00", "00:00"
Creates the Fri_thru_Mon time range, which is 9:00 a.m. to 5:00 p.m., Friday, Saturday, Sunday, and Monday:
sp_add_time_range Fri_thru_Mon, Friday, Monday, "09:00", "17:00"
Creates the Wednesday_night time range, which is Wednesday from 5:00 p.m. to 12:00 midnight:
sp_add_time_range Wednesday_night, Wednesday, Wednesday, "17:00", "00:00"
Adaptive Server includes one named time range, the “at all times” time range. This time range covers all times, from the first day through the last of the week, from 00:00 through 23:59. It cannot be modified or deleted.
Adaptive Server generates a unique ID number for each named time range and inserts it into the systimeranges system table,
When storing a time range in the systimeranges system table, Adaptive Server converts its startday and endday values into integers. For servers with a default language of us_english, the week begins on Monday (day 1) and ends on Sunday (day 7).
It is possible to create a time range that overlaps with one or more other time ranges.
Range days are contiguous, so the days of the week can wrap around the end to the beginning of the week. In other words, Sunday and Monday are contiguous days, as are Tuesday and Wednesday.
The active time ranges are bound to a session at the beginning of each query batch. A change in the server’s active time ranges due to a change in actual time has no effect on a session during the processing of a query batch. In other words, if a resource limit restricts a query batch during a given time range but a query batch begins before that time range becomes active, the query batch that is already running is not affected by the resource limit.
The addition, modification, and deletion of time ranges using the system procedures does not affect the active time ranges for sessions currently in progress.
If a resource limit has a transaction as its scope, and a change occurs in the server’s active time ranges while a transaction is running, the newly active time range does not affect the transaction currently in progress.
Changes to a resource limit that has a transaction as its scope does not affect any transactions currently in progress.
For more information on time ranges, see the System Administration Guide.
Only a System Administrator can execute sp_add_time_range.
System procedures sp_add_resource_limit, sp_drop_time_range, sp_modify_time_range