repeat_interval in DBMS_SCHEDULER.create_job - for the 2nd day of each month

Hi all

I want to clarify in the repeat_interval the Scheduler for this task must be run on the second of each month at 20:00.
I've been racking my brains out but nothings coming out.

Any suggestions?

You probably want a range like this:

FREQ=MONTHLY;BYMONTHDAY=2;BYHOUR=20;BYMINUTE=0;BYSECOND=0;

You can use the DBMS_SCHEDULER. EVALUATE_CALENDAR_STRING function to test, as follows:

SQL > DECLARE
  2  start_date        TIMESTAMP;
  3  return_date_after TIMESTAMP;
  4  next_run_date     TIMESTAMP;
  5  BEGIN
  6  start_date :=
  7    to_timestamp_tz('01-JAN-2003 10:00:00','DD-MON-YYYY HH24:MI:SS');
  8  return_date_after := start_date;
  9  FOR i IN 1..5 LOOP
 10    DBMS_SCHEDULER.EVALUATE_CALENDAR_STRING(
 11      'FREQ=MONTHLY;BYMONTHDAY=2;BYHOUR=20;BYMINUTE=0;BYSECOND=0;',
 12      start_date, return_date_after, next_run_date);
 13  DBMS_OUTPUT.PUT_LINE('next_run_date: ' || next_run_date);
 14  return_date_after := next_run_date;
 15  END LOOP;
 16  END;
 17  /
next_run_date: 01/02/2003 08:00:00.000000 PM
next_run_date: 02/02/2003 08:00:00.000000 PM
next_run_date: 03/02/2003 08:00:00.000000 PM
next_run_date: 04/02/2003 08:00:00.000000 PM
next_run_date: 05/02/2003 08:00:00.000000 PM

Tags: Database

Similar Questions

  • for the 25th day of each month in Date function

    Dear all,

    I want to want to get the 25th day of each month
    as.
    Select sysdate from dua.



    Concerning
    SQL> select trunc(sysdate,'MM')+24 "Day" from dual;
    
    Day
    ---------
    25-MAY-13
    
  • Find the 2nd Sunday of each month in a report

    Hello

    I have the data of EMP_Name and Join_Date. I have to build a dashboard report where

    1. In the dashboard, there is a command prompt. If I select a year and a month then, the report is expected to show that the data of the respective month.
    2. This report will show the employees who joined the company only after the 2nd Sunday of each month until the end of the month.

    Inputs/suggestions, how to build it?

    Thanks in advance.

    You have a question, Yes... a SQL query... OBIEE do not mean SQL but LSQL, your query will be not really usable like this...

    You're right, it seems that when the first day of the month is a Saturday he jump 1 week...

    The correct formula for the 3rd Friday is:

    TIMESTAMPADD (SQL_TSI_DAY, (14 + 6-CASE WHEN DAYOFWEEK (TIMESTAMPADD (SQL_TSI_DAY, 1-DAYOFMONTH (CURRENT_DATE), CURRENT_DATE)) = 7 THEN 0 END ELSE DAYOFWEEK (TIMESTAMPADD (SQL_TSI_DAY, 1-DAYOFMONTH (CURRENT_DATE), CURRENT_DATE))), TIMESTAMPADD (SQL_TSI_DAY, 1-DAYOFMONTH (CURRENT_DATE), CURRENT_DATE))

    If instead of CURRENT_DATE you want to use your own column date just to replace in the formula and it works.

  • How to get the date for the first Monday of each month

    Dear members,

    How to get the date for the first Monday of each month.

    I wrote the following code

    SELECT decode (to_char (trunc (sysdate + 30, 'MM'), 'DAY'), 'MONDAY', trunc (sysdate + 30, 'MM'), NEXT_DAY (trunc (sysdate + 30, 'MM'), "LUN")) FROM DUAL

    But he looks at complex bith.

    Abhishek

    Published by: 9999999 on 8 March 2013 04:30

    Use the IW format - it will make independent NLS solution. And all you need is truncated 7th day of each month using IW:

    select  sysdate current_date,
            trunc(trunc(sysdate,'mm') + 6,'iw') first_monday_the_month
      from  dual
    /
    
    CURRENT_D FIRST_MON
    --------- ---------
    08-MAR-13 04-MAR-13
    
    SQL> 
    

    Here is the list of the first Monday of the month of this year:

    with t as(
              select  add_months(date '2013-1-1',level-1) dt
                from  dual
                connect by level <= 12
             )
    select  dt first_of_the_month,
            trunc(dt + 6,'iw') first_monday_the_month
      from  t
    /
    
    FIRST_OF_ FIRST_MON
    --------- ---------
    01-JAN-13 07-JAN-13
    01-FEB-13 04-FEB-13
    01-MAR-13 04-MAR-13
    01-APR-13 01-APR-13
    01-MAY-13 06-MAY-13
    01-JUN-13 03-JUN-13
    01-JUL-13 01-JUL-13
    01-AUG-13 05-AUG-13
    01-SEP-13 02-SEP-13
    01-OCT-13 07-OCT-13
    01-NOV-13 04-NOV-13
    
    FIRST_OF_ FIRST_MON
    --------- ---------
    01-DEC-13 02-DEC-13
    
    12 rows selected.
    
    SQL> 
    

    SY.

  • use to insert the last day of each month

    Hi, I wrote this code but it did not insert the 20 December and it is January 1, and next time running is 31 January... I would like to work to make this insert every last day of each month...
    begin
      sys.dbms_job.submit(job => :job,
                          what => 'INSERT INTO hisrtu 
                                            SELECT rtunum, linked, dbchkd, chaqty, dbvald, ctrltr, meaadj, qtyrtu, month, year, entity, rtunam 
                                            FROM qtyrtu;',
                          next_date => to_date('31-10-2010 01:00:03', 'dd-mm-yyyy hh24:mi:ss'),
                          interval => 'SYSDATE +30');
      commit;
    end;
    /
    I don't know if it's because I assigned the date 31-10... In November it's just but December has not...

    Best regards, hope you can help me.

    I use oracle 9i

    Hello

    If you want the job to run at 02:00 the last day of the next month, then the desired argument is:

    interval => 'ADD_MONTHS (TRUNC (SYSDATE, ''MONTH''), 2) - (22 / 24)'
    

    In other words, if she finishes running at 02:30 on 31 January, then
    TRUNC (SYSDATE, 'MONTH') will be at 00:00:00 January 1
    ADD_MONTHS (TRUNC (SYSDATE, 'MONTH'), 1) will be March 1st at 00:00:00
    ADD_MONTHS (TRUNC (SYSDATE, 'MONTH'), - 1) (22 / 24) will be 22 hours earlier, i.e. 02:00 on the last day of February.

    logandro wrote:
    I don't know if it's because I assigned the date 31-10... In November it's just but December has not...

    Do you mean this line?

    next_date-online to_date (October 31, 2010 01:00:03 ',' dd-mm-yyyy hh24:mi:ss'),

    I don't think that's a problem. The next_date specifies only when it work baptisms. I guess he ran on October 31; you said it was running well on 30 November, 30 days after that. Something has to happen after November 30.

    Note that the interval argument is relative when the task completes. If a task takes 30 minutes to run, then

    interval => 'SYSDATE +30'
    

    means that, if it turns to
    01:00:03 October 31, then it will run again about
    01:30:03 November 30, around
    02:00:03 on December 30.
    02:30:03 January 29 and so on. If your business does that for a few seconds, it won't matter much.

    If you decide to use LAST_DAY, don't forget not that the hours-minutes-seconds referring LAST_DAY are the same as those of his argument.

  • Nomination for the third Wednesday of each month

    How can I set up my monthly calendar to an event that occurs every third Wednesday of the month?  Thank you.

    Hello

    • You use windows calendar or any other program?

    If sa is the Windows Calendar, then it is not possible to do.

    http://Windows.Microsoft.com/en-us/Windows-Vista/customize-Windows-Calendar

    Diana

    Microsoft Answers Support Engineer

  • Outlook Express downloads e-mail messages for the 2nd time which have been read and deleted a few weeks ago.

    Outlook Express downloads e-mail messages for the 2nd time which have been read and deleted a few weeks ago.  This happens periodically.  Repeated messages are usually a week.

    Maybe they are still on the server (server of your ISP). Make sure that you don't leave copies of messages downloaded from the ISP server that may cause duplicate messages to download.

    It's the only thing I can think of.

    If you are unsure how to check your messages via the Internet site of the ISP, then check with them about how you do that. TaurArian [MVP] 2005-2010 - Update Services

  • Download DVD Photoshop for the 2nd time

    I updated my windows 8 PC and therefore having to download my photoshop 11 and Prime Minister 11 DVD for the 2nd time, the Prime Minister is OK the photoshop won't download, they were both very well the first time? d

    You can download the demo version of the software through the page linked below and then use your current serial number to activate it.

    Don't forget to follow the steps described in the Note: very important article Instructions on the pages to download to this site or the download may not work properly.

    Photoshop/Premiere Elements 11:

    l http://prodesigntools.com/Photoshop-Elements-11-Direct-Download-Links-PSE-Premiere-pre.htm

  • How to get the same day of a month each year in the DB (update a flag)

    Hello

    I'm trying to make a update for a table of flag request in our database that contains the dates and the Pavilion columns. Currently the system have dates for the next ten years. The flags are updated with the values 0 or 1, if a particular date falls under the criteria required.

    I need to update the column flag for the same day of the month of each year. for example, 2nd Sunday of October. The value must be updated in all the years in the table. Currently I use the following query to update of the current year.

    UPDATE FILTERCALENDAR SET YEAR_WINDOW = 1 WHERE c_date = NEXT_DAY (TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1) * 7;

    and for the next year as

    UPDATE FILTERCALENDAR SET YEAR_WINDOW = 1 WHERE c_date = add_months (NEXT_DAY (TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1) * 7, + 12)-1;

    This isn't a great way to do it because he does not take care of leap years, and it does not scan and update values across the table for all the years correctly.

    Can someone help me fix this please.

    Welcome to the forum!

    Whenever you provide post your Oracle version 4-digit (result of SELECT * FROM V$ VERSION)
    >
    and for the next year as

    UPDATE FILTERCALENDAR SET YEAR_WINDOW = 1 WHERE c_date = add_months (NEXT_DAY (TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1) * 7, + 12)-1;
    >
    Why do you use "2013" in the TO_DATE for the year next rather than use simply '2014 '?

    You said it works
    >
    UPDATE FILTERCALENDAR SET YEAR_WINDOW = 1 WHERE c_date = NEXT_DAY (TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1) * 7;
    >
    Just interview the years from your table (list of the separate years) and use the query above on them.

    SELECT DISTINCT TO_CHAR(c_date, 'yyyy') FROM FILTERCALENDAR
    

    Or use this predicate

    WHERE c_date = next_day(last_day(add_months (c_date, -1)), 'SUNDAY') + 7
       AND TO_CHAR(c_date, 'mm') = '10'
    

    1 TO_CHAR ensures that the line has a month to October.
    2 ADD_MONTHS goes to Sept. 1.
    3 LAST_DAY going until the last day of September.
    4 NEXT_DAY goes to the first Sunday in October
    5 + 7 is going to the second Sunday in October

  • I need an event to repeat the 1st Thursday of each month; the only option I have is every 8th 6 or each day.

    I wish I had a repetitive on the first event and the third Thursday of each month. I can't make it a monthly event repeated the same day of the week.

    Also, I get an overlay on my Yahoo screen that says I must be disconnected or closed another page and I need to connect when I did this. Is this a problem of Yahoo?

    For your repeat again, I guess that's your Yahoo calendar? This isn't a matter of Firefox, I suggest you try to communicate with yahoo.

    For the other questions, try the following:
    Upgrade to Firefox 15. Then, Firefox Refresh - reset the parameters and modules

  • For the second time in two months, all my messages in the Inbox are not there. Only the SUBJECT and the FROM is left. Tried to 'fix this folder' and lost ALL

    For the second time in two months, all my messages in the Inbox are not there. Only the SUBJECT and the FROM is left.

    Tried to 'fix this folder' and ALL - lost ALL the Inbox.

    The file is still there and works well...

    How can I stop it and what are the causes?

    Thank you all, Gabe

    If you have the file somewhere on your hard drive, export and import tools it will be important back to Thunderbird.

    https://addons.Mozilla.org/en-us/Thunderbird/addon/ImportExportTools/

    Instructions http://chrisramsden.vfast.co.uk/3_How_to_install_Add-ons_in_Thunderbird.html

  • For the second time in six months, Thunderbird seems to have lost all my emails content.

    I have Thunderbird loaded on a MacBook Pro. For the second time in six months, disappeared the conent of all emails. I have a list of emails, but the content does not appear in the reviewing pane or if I open the e-mail. I made no changes to the computer Professor at Thunderbird. It's very frustrating! Any ideas as to what is happening?
    Mike

    Do you also have an anti virus program for the second time in six months has quarantined you Inbox?

  • I signed up for the photos of 10 a month, and I chose pictures of licenses.  However, when I download the pictures I have a license on my desk always have the "stock" of writing through them.  How can I remove this?  Thank you

    I signed up for the photos of 10 a month, and I chose pictures of licenses.  However, when I download the pictures I have a license on my desk always have the "stock" of writing through them.  How can I remove this?  Thank you

    Follow these steps to download: I downloaded my 10 free images and they all have the Adobe watermark on them, so I can't use them. Why do they have a watermark on them?

  • Is it possible to be charged for the entire year instead of monthly?

    Is it possible to be charged for the entire year instead of monthly?

    Hey, Francine.

    Please reach out to the Adobe Customer Service because they would help you with the same.

    Contact | Adobe

    Kind regards

    Ana Maria

  • How to find the first Sunday and the second Saturday of each month

    Hi all

    How to find the first Sunday and the second Saturday of each month

    Thank you

    Oracle Database 11 g Enterprise Edition Release 11.1.0.7.0 - 64 bit Production

    994122 wrote:

    Hello

    I need to pass the months parameter how to do this? like Jan, Feb etc... (one of those)

    Do you have a procedure?

    Should you output only for the months you passed in the parameter?

    The easiest way is to set the parameter as date. When you go such as p_date as DATE ' 2014-10-01', then you can

    PROCEDURE two_dates)

    p_date IN DATE

    p_first_sunday DATE

    p_second_saturday DATE

    )

    IS

    BEGIN

    p_first_sunday: = NEXT_DAY (TRUNC (p_date, 'MM') - 1, TO_CHAR (DATE ' 2014-10-12', 'DAY'));

    p_second_saturday: = NEXT_DAY (TRUNC (p_date, 'MM') - 1, TO_CHAR (DATE ' 2014-10-11', 'DAY')) + 7;

    END two_dates;

    Or you describe what you need.

Maybe you are looking for