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).

AHiggins
  • 7,029
  • 6
  • 36
  • 54
Martijn
  • 11,964
  • 12
  • 50
  • 96

2 Answers2

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.

Anthony K
  • 2,543
  • 4
  • 32
  • 41
  • 2
    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. – Fosna May 20 '15 at 11:29
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.

CodeNaked
  • 40,753
  • 6
  • 122
  • 148