Display off days of employees

How to generate every day of Nth week (eg. second Saturday) between two dates?

From_date and two_date belongs to the different months for example: 21/01/2011 to 20/02/2011

Second Saturday between two dates.

The result would be 02/12/2011.

Help, please...

I answered your message off day rules this morning. But unfortunately, the answer has been deleted and the thread is locked. Just noticed that you already asked the question in the case. So answer again (thanks to SQL Developer, I could find the SELECTION from history)

SQL> with tsht_offday_general_rules
  2  as
  3  (
  4  select 1 rule_id, to_date('20/09/2011', 'dd/mm/yyyy') wef, 'M' employee_type
  5    from dual
  6  union all
  7  select 2 rule_id, to_date('28/09/2011', 'dd/mm/yyyy') wef, 'M' employee_type
  8    from dual
  9  ),
 10  tsht_offday_general_rules_dtl
 11  as
 12  (
 13  select 1 rule_id, 0 week_no, 1 week_day
 14    from dual
 15  union all
 16  select 1 rule_id, 2 week_no, 7 week_day
 17    from dual
 18  union all
 19  select 1 rule_id, 4 week_no, 7 week_day
 20    from dual
 21  union all
 22  select 2 rule_id, 0 week_no, 1 week_day
 23    from dual
 24  union all
 25  select 3 rule_id, 1 week_no, 7 week_day
 26    from dual
 27  union all
 28  select 4 rule_id, 3 week_no, 7 week_day
 29    from dual
 30  ),
 31  input_date
 32  as
 33  (
 34  select to_date('20/09/2011', 'dd/mm/yyyy') from_date
 35       , to_date('21/10/2011', 'dd/mm/yyyy') to_date
 36    from dual
 37  ),
 38  input_date_expand
 39  as
 40  (
 41   select from_date + (level-1) dt
 42        , ceil(extract(day from from_date + (level-1))/7) week_no
 43        , case to_char(from_date + (level-1), 'FMDAY')
 44               when 'SUNDAY' then 1
 45               when 'MONDAY' then 2
 46               when 'TUESDAY' then 3
 47               when 'WEDNESDAY' then 4
 48               when 'THURSDAY' then 5
 49               when 'FRIDAY' then 6
 50               when 'SATURDAY' then 7
 51          end week_day
 52     from input_date
 53  connect
 54       by level <= to_date - from_date + 1
 55  ),
 56  leave_rule
 57  as
 58  (
 59  select h.rule_id
 60       , h.wef
 61       , h.wef_end
 62       , h.employee_type
 63       , d.week_no
 64       , d.week_day
 65    from (
 66            select rule_id
 67                 , greatest(wef, i.from_date) wef
 68                 , nvl(lead(wef) over(order by rule_id) - 1, i.to_date) wef_end
 69                 , employee_type
 70              from tsht_offday_general_rules
 71             cross join input_date i
 72         )  h
 73    join tsht_offday_general_rules_dtl d
 74      on h.rule_id = d.rule_id
 75  )
 76  select a.dt
 77       , a.week_no
 78       , a.week_day
 79    from input_date_expand a
 80    join leave_rule b
 81      on a.dt between b.wef and b.wef_end
 82     and (a.week_no = b.week_no or b.week_no = 0)
 83     and a.week_day = b.week_day;

DT           WEEK_NO   WEEK_DAY
--------- ---------- ----------
24-SEP-11          4          7
25-SEP-11          4          1
02-OCT-11          1          1
09-OCT-11          2          1
16-OCT-11          3          1

SQL>

Tags: Database

Similar Questions

  • Windows 7 does not open the windows in the taskbar. The content seems to be displayed off the screen

    Windows 7 does not open the windows in the taskbar. The content seems to be displayed off the screen. It started after the uninstall of Registry Mechanic and PC Tools, but this cannot be bound. IE 9 seems to be particularly affected. So do not display all of the windows that show on the taskbar.

    Use the Windows logo key & left arrow several times for each windows application through their positions until they appear on the screen.

    This problem is normally reported after someone used an external monitor as the applications try to open in the same position they had when they were last open - so if there was an external monitor last time now disconnected, they will try to open it in the middle of nowhere.

    I know not, or the other tools that you mention, but if they are registry cleaners then they could also affect other parts of your system.

  • Help needed in the list item... need display a selected Department employees

    Hi all
    I am very beginner in D2K technology. I use Forms 10g.
    Could you please help me...

    I created a list item that contains dept_id = 10, 20, 30...

    My requirement is when I change the value of the dept_id (select dept_id = 20), the employees belong to this desire to display dept (to display 5 dept 20 employees).

    I created two block - block2, block3 hepatitis has

    In block2, there is a list item

    Block3, there is an element of the screen and I've changed the number of properties displayed in block 10.

    I have atteched a trigger when-list-changed and the code is:
    Select last_name in: block3.item14 of employees where department_id =:block2.item4;

    But it does not work...

    Thanks in advance,
    Tapan.

    Published by: user630863 on August 8, 2010 21:20

    Published by: user630863 on August 8, 2010 21:55

    Well, the 'right' wa would be in the basic block 3 on the emp table database, set the somthind as where clause

    DEPTNO=:BLOCK.THE_LIST_ITEM:
    

    If you want to stay with the 'wrong' way to fill th eblock by yourself, try something like

    GO_BLOCK('BLOCK3');
    CLEAR_BLOCK(NO_VALIDATE);
    FOR rec IN cursor LOOP
      IF :SYSTEM.RECORD_STATUS!='NEW' THEN
        CREATE_RECORD;
      END IF;
      :BLOCK3.LASTNAME:=rec.LASTNAME;
    END LOOP;
    
  • need to display 365 days a year


    Hi all
    I use oracle 10g.
    I have to post 365 days a year.
    How can I view using the query.
    for example, I display from 1 January 2009 to 31 December 2009.
    If anyone knows it please suggest what are the possible ways to display 365 days a year.



    Kind regards
    Eliane.

    Please write the subject and marked as replied.

    Kind regards.

    LOULOU.

  • Loading with iPhone display off / sleep

    Greeting card,

    I already did a lot of research, but I'm not sure that previous discussions fully answer my question so here:

    In the past, I plugged my iPhone on my MacBook, and then turned the screen turned off (press and hold the power button / stop for a few seconds or even close the screen) and he would stay in charge. I even used to car rides along when I needed a load, I would plug it in, turn on the screen and sign, then activate the display back and she would charge. It was a very handy feature. The problem is that all of a sudden (since someone else was charging their phones on my computer honestly) it will no more work. Now when I charge my phone and the display stops, it stops just the load after 10 seconds. Needless to say that it is very annoying because I want my phone to charge all night and other times when I do not use the computer. Keep in mind that it is when the computer is plugged in, but it worked before without being plugged as well.

    I'm not quite sure if the computer goes to sleep or not, but I just do the temporary power button thing to make it dark, then he used to continue to load, and if I want to put everything back up I just click any button. Does anyone have an idea why she might have changed? I don't mess with one of the options so that it seems strange to stop working randomly and is quite inconvenient power saving.

    Thanks guys and sorry for the long question!

    Alex

    Hey,.

    can you check if the 'power Nap' option is active and other parameters in "energy saver" as the "insert disc hard mode '?

    Perhaps that is the question, I tried with my macbook pro late 2015 and still dependents in mode iPhone 'sleep'.  I have not tried with the iPad.

  • display off by keyboard

    Do you know a tool that can turn off the display of keyboard?

    "monitor off utility.

  • off day and more updated causes do not install during the update installation

    A few weeks ago, my vista has received an update that requires a restart of my computer. When he reeached to the step where it says "Please don't close or turn off your computer", my computer was off for "Installing update 1 of 5". " The computer was returned, an attempt was made to re - install these updates. I left it on all day, but it was still saying "Installation update 1 of 5". I leave he was frozen, so I repeated the process, but after more extended time there was still at this stage. Now another update came out and it is now stuck on "Installing update 1 of 6.

    Updates will not install question how long I leave it on.

    EDIT: I discovered that the update on my vista is blocked is "Updating security for Microsoft Office System 2007 (KB978380)"

    0 x 80240016 is to "try to install so that another installation happens or reboot is pending"

    Error message when you try to install the updates on the Windows Update Web site or the Microsoft Update Web site: "0 x 80240016.
    http://support.Microsoft.com/kb/957307

    As for your office update problem, the update appears not applicable to your office installation.

    You may need to repair/reinstall your office installation (providing you have the original media and product code).

    TaurArian [MVP] 2005-2010 - Update Services

  • Windows 7 turns the display off, but doesn't go to sleep

    My Windows 7 will not more in mode 'sleep'.  It will turn the display at 5 minutes (by the Power Options settings), but it won't put the computer to sleep after 30 minutes.  The screen is off, but the hard drive flashes.  The power light on the computer is turned on, not the sleep mode color amber.

    If I choose Start, stop, sleep, the computer enters mode "Eve".

    How can I get the computer to go to sleep automatically?

    Follow the below mentioned steps to solve the problem:
    1. click on start and open Control Panel.
    2. open Power Options then select the option to change when the computer sleeps.
    3. click on change advanced power settings, under Multimedia settings make sure that you don't have to stop the idling to sleep

  • Re: Powers of display off every 15 min sp10-304

    Can anyone help, the screen turns off every 15 minutes, but the power option is set to never.
    I can t access the Windows power options where it went to power after 15 minutes

    Mick

    Hello!

    First of all, what laptop do you have exactly?

    And I don t understand why you cannot access the Windows power options.
    Maybe you can explain this more accurate.

    Good bye

  • Satellite L30 - display off after will point

    After that my laptap wakes up after hibernation display does not cut after the specified inactivity time.
    Instead, it empties but is still lit.
    Before hibernation, the automatic display stops ok.

    Any suggestions on a fix would be appreciated.

    Hello

    There is only one real solution;
    BIOS and update the graphics card driver! ;)

    You will find many discussions on similar problems and most of the users solved do a BIOS and update graphic card driver

    So try it!

    Good luck

  • LED backlight display off when the power supply is connected

    Basically, what happens is every time others or so when I plug my T420 in power, the backlight of the screen turns off completely. The screen is always on because if I look close enough I can still see whats on the screen. All the other power lights, Thinklight and other indicators remain on. I can't tell if this is a problem of motherboard, power supply problem or something different, but the problem is very frustrating because I put the computer to sleep and then wake it up back up to continue to use the machine. Any help is appreciated.

    Using the search I found this:

    Link to the Knowledge Base

    This problem is well known and seems to be a hardware error. Then try to contact the after-sales service and send in your thinkpad. Or you can use the workaround described in the link above.

    Moderator edit: link fixed.

  • I5screen W700 keeps dimming (with gradation display off)

    I set the Max screen brightness (I love my screens to be as bright as I can), but for some reason, no matter what I do (including them turn off screen dimming) he maintains in gradation occasionally and I find myself with a screen dark light as I've got low light. Sometimes it works and I'm having a brilliant screen another time sound really dim. Any suggestions?

    by disabling the dimming, you do charm bar, settings, change the setting, general, under the screen of pc have you turn off automatically set the brightness of my screen...

  • Why my Windows Defender displays off when I turned on?

    Why did my show as windows Defender off I turn?

    What other security programs you have running? Many as MSE, Norton, McAfee, AVG, etc., will stop Windows Defender because they have the same functionality, and having two programs running at the same time and make security the same work can lead to conflicts. This is by design and must be accepted by the user.

  • Some how the area of notification in the taskbar displays "time, day of week and date."

    How can I get that back at once.  The taskbar is not locked and I can not click and drag the smaller bar.  I can drag to disappear.

    This is normal when the taskbar are large enough to display three lines of text.  Make the taskbar smaller change in return.   I do not know why you can not do.

  • Display the days of exercise

    Hello

    If fiscal year starts from April 01... in a given year, then please suggest how show all day until the year financial beginning of sysdate.

    Hello

    This comes from >, but I realize that I made a mistake ;-)

    To_char (sysdate, 'MM')< '04' ="" checks="" if="" the="" current="" date="" is="" strictly="" before="" 01-apr="" or="" after="" this="" date.="" from="" this="" we="" have="" to="" take="" one="" decision:="" either="" we="" will="" start="" from="" 01-apr="" of="" the="" year="" before,="" or="" of="" the="" year="" before="" the="" year="">

    As TRUNC (sysdate, 'YYYY') is the 01 - JAN of this year, to return to the 01 - April of the previous year, subtract 9 months and one year further back, we need to subtract 12 extra months, so 9 + 12, so 21 months (and No 23, as I wrote it wrongly).

    Then I subtracted a day more in the "+ LEVEL" it is done after, and LEVEL will have the values 1, 2,...

    Example for today (January 2015): TRUNC (sysdate, 'MM') = '01', then we are in the case of "THEN": ADD_MONTHS (TRUNC (sysdate, 'YYYY'),-21) - 1 = 31 March 2013

    And if we were a few days ago (December 2014): TRUNC (sysdate, 'MM') = '12', then we would have been in the case of "ELSE": ADD_MONTHS (TRUNC (this_sysdate, "YYYY"),-9) - 1 = 31 March 2013 also.

    It will be the same until March 31, 2015, then for example on 4 April 2015 we will be in the case of "ELSE" but with a date with "YYYY = 2015" and the calculation will give: ADD_MONTHS (TRUNC ( <04 apr="" 2015="">>, 'YYYY'), - 9)-1 = 31 March 2014

    So: Here's the statement again, but with correction (21 instead of 23)

    SELECT the BOX WHEN TO_CHAR (sysdate, 'MM')<>
    THEN ADD_MONTHS (TRUNC (sysdate, 'YYYY'), - 21)-1
    ELSE ADD_MONTHS (TRUNC (sysdate, 'YYYY'), - 9)-1
    END
    + A day LEVEL
    OF the double
    CONNECT BY LEVEL<= trunc(="" sysdate="">
    -CASE WHEN TO_CHAR (sysdate, 'MM')<>
    THEN ADD_MONTHS (TRUNC (sysdate, 'YYYY'), - 21)-1
    ELSE ADD_MONTHS (TRUNC (sysdate, 'YYYY'), - 9)-1
    END
    ;

    Best regards

    Bruno

Maybe you are looking for

  • Satellite P100-115 - vertical lines to appear on the screen

    Hello. My Satellite P100-115 is 2.5 years but yesterday a thin vertical line appeared on the screen.I already checked this problem by connecting an external monitor. The line does not appear on the external display.Could you tell me what might get hu

  • Drivers HP Elite 7500 XP Downgrade

    Hi guys,. I'm trying to downgrade a desktop PC HP Elite 7500 for work. I have XP Pro installed, but miss me the following drivers. PCI Simple Communications controller- PCI\VEN_8086 & DEV_1E3A & SUBSYS_2AD5103C & REV_04\3 & 11583659 & 0 & B0 SM Bus c

  • Impossible to uninstall Avira in Panel, says file does not exist

    Heyin fact I uninstalled avira antivirus control panel... n, then I installed AVG...subsequently due to a problem I once more for the system restore tryn it became a successnow my laptop search en avira who was present at the date of return... I trie

  • MicroTek Scanmaker 4800 patch of compatibility for Windows 7

    I have a MicroTek Scanmaker 4800, who gave me the results very years.  My old desktop with XP operating system Sony has died and I have a Toshiba Satellite L755-S5248 with Windows 7 Home Premium OS.  I can't load the Scanmaker CD on the Toshiba Softw

  • BlackBerry Q10 emails read in Outlook are removed on my Q10

    Hello On my btinternet email account I had to configure it as IMAP. Q10 sends and receives emails so that seems to work OK. However, if I find an email in Outlook 2007, it is deleted on my Q10. How can I change that so it is kept on the BB please? (I