Are end dates for sql server job schedules inclusive or exclusive
Asked Answered
P

2

8

I have a schedule that does something daily, every two hours in a time interval. I want to set an end date for this schedule, but I'm wondering if it is inclusive or exclusive. In other words, if I set the end date at march 26, will today be the last day it runs, or tomorrow (it is march 25 today).

Perorate answered 25/3, 2011 at 12:25 Comment(0)
H
1

There is also an end time that needs to be considered. Any job that would run after the end date/time will not be run. So it's effectively exclusive.

From MSDN:

SQL Server Agent automatically disables schedules that are no longer current. If you edit the schedule after it has been disabled by SQL Server Agent, you must explicitly reenable it. Schedules are disabled if:

They are defined to run on a recurring schedule, and the end date has passed.

There were also some problems with earlier versions of SQL Server, with regards to end dates.

Hooghly answered 28/3, 2011 at 13:9 Comment(1)
Could you please check your answer against the higher rated answer to check if it is valid?Tokay
T
15

If you look in the msdb database, using the sysschedules_localserver_view view, then you can see the schedule along with an end date (active_end_date = March 26) and an end time (active _end_time) which will most likely be 235959, meaning that any job scheduled with an end date of March 26 will run on March 26, and the first day "missed" will be the 27th. I can confirm this from bitter experience that with an end date set in the Job - Schedules dialog, the job will run on that date. So the end date is Inclusive.

Tractile answered 6/8, 2012 at 5:23 Comment(1)
End date in SQL Agent jobs is inclusive. I have proved it by creating simple task that adds rows to some dummy table. It was scheduled to run every two seconds. End Date was today. Rows were inserted. When End Date was set to yesterday, inserting of rows has stopped. I suggest to check it yourself.Helladic
H
1

There is also an end time that needs to be considered. Any job that would run after the end date/time will not be run. So it's effectively exclusive.

From MSDN:

SQL Server Agent automatically disables schedules that are no longer current. If you edit the schedule after it has been disabled by SQL Server Agent, you must explicitly reenable it. Schedules are disabled if:

They are defined to run on a recurring schedule, and the end date has passed.

There were also some problems with earlier versions of SQL Server, with regards to end dates.

Hooghly answered 28/3, 2011 at 13:9 Comment(1)
Could you please check your answer against the higher rated answer to check if it is valid?Tokay

© 2022 - 2025 — McMap. All rights reserved.