Skip to Main Content
  • Questions
  • Schedule Job runs Every first and third thursday of every month.

Breadcrumb

Question and Answer

Connor McDonald

Thanks for the question, HEMENDRA.

Asked: February 26, 2016 - 8:52 am UTC

Last updated: February 26, 2016 - 10:05 am UTC

Version: Oracle Database 11g

Viewed 10K+ times! This question is

You Asked

Hi Tom,

I want to schedule a job which run Every first and third Thursday of every month say at 16:00 o'clock.

If possible could you please suggest how can I proceed for the same.

Thanks in Advance...

and Chris said...

You can use the BYDAY property of the repeat interval for the scheduler. You can use this to set jobs to run on the nth weekday of the month. e.g.

FREQ=MONTHLY; BYDAY=1THU,3THU;


Or if you wanted the 1st Monday, 3rd Wednesday and 5th Friday it would be:

FREQ=MONTHLY; BYDAY=1MON,3WED,5FRI;


If you want it to run at a specific time on these days, use the BYHOUR, BYMINUTE & BYSECOND options:

FREQ=MONTHLY; BYDAY=1THU,3THU; BYHOUR=16; BYMINUTE=0; BYSECOND=0


To submit the job, run:

BEGIN
    DBMS_SCHEDULER.CREATE_JOB (
            job_name => 'TEST_JOB',
            job_type => 'PLSQL_BLOCK',
            job_action => 'begin your_code_here; end;',
            number_of_arguments => 0,
            start_date => NULL,
            repeat_interval => 'FREQ=MONTHLY; BYDAY=1THU,3THU;',
            end_date => NULL,
            enabled => FALSE,
            auto_drop => FALSE,
            comments => '');
      
    DBMS_SCHEDULER.enable(
             name => 'TEST_JOB');
END;
/

Rating

  (1 rating)

Is this answer out of date? If it is, please let us know via a Comment

Comments

HEMENDRA BISHT, February 26, 2016 - 12:06 pm UTC


More to Explore

DBMS_SCHEDULER

More on PL/SQL routine DBMS_SCHEDULER here