0

This may be a daft question as it is coming from a foggy mind. I am trying to determine when the next interval will be of a job that is scheduled to fire on the last day of every x month. In a query, I have calculated ThisMonthsJobTime, ScheduleStartJobTime and I am trying to determine the case on how to know when, at any given point in time, when is the NextFiringTime.

Let's say I have a SQL Server job starting at 02/05/2025 10:30:00 PM and it has been configured to run on the last day of the month at 10:30:00 PM every 2 months.

The @freq_recurrence_factor = 2

I am reading this as it will fire on 2/28, skip 3/31 and 4/30, and fire again on 5/31 and so on. Can I get a confirmation on this as the documentation does not go into detail about that?

To the query question. Is there any date time math magic that can be used to determine the next job run time at any given point in time? I have been working some stuff.

SELECT
   IntervvalOfX, 
   ScheduleBeginDate,
   DATEADD(DAY,DATEDIFF(DAY,ScheduleBeginDate, EOMONTH(scheduleBeginDate)),ScheduleBeginDate) AS ScheduleStartJobTime,
   NextStartJobTime = 'some math based on start-time, getdate() and IntervalOfX?'
 FROM
   MyScheduleTable
3
  • 1
  • 1
    Do you need to know the internal working or you are just interested in getting the next run date / time ? you can use sp_help_job to find out the information
    – Squirrel
    Commented 2 days ago
  • That is the answer. I was not aware of this procedure, thank you. If would like to make this the answer, then I will accept it.
    – Ross Bush
    Commented 2 days ago

0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Browse other questions tagged or ask your own question.