Get all Iso Weeks when an employee had at least 5 days holliday

Hi all,
I'm trying to query to get all Iso Weeks (Calendar weeks) when an employee had at least 5 days hollidays.
select HOLLIDAY_FROM,HOLLIDAY_TILL,to_char(HOLLIDAY_FROM,'iw') from_week,to_char(HOLLIDAY_TILL,'iw') till_week from HOLLIDAY;
HOLLIDAY_FROM HOLLIDAY_TILL FR TI
12-SEP-11 26-SEP-11 37 39
In this example an employee had holliday from Monday in the week # 37 till Monday in the week # 39.
So I would need to get the weeks 37 and 38 as a result, because in this weeks the employee had 5 days hollidays (saturday and sunday are weekend and are not counted)
Any help would be appreciated!

It looks like I misunderstood your question. To get IW weeks where all 5 weekdays were holidays/vacation use:
SELECT  TO_CHAR(HOLLIDAY_FROM + LEVEL - 1,'IW') week
  FROM  HOLLIDAY
  WHERE TO_CHAR(HOLLIDAY_FROM + LEVEL - 1,'DY','NLS_DATE_LANGUAGE=ENGLISH') NOT IN (
                                                                                    'SAT',
                                                                                    'SUN'
  CONNECT BY HOLLIDAY_FROM + LEVEL - 1 <= HOLLIDAY_TILL
  GROUP BY TO_CHAR(HOLLIDAY_FROM + LEVEL - 1,'IW')
  HAVING COUNT(*) = 5
/Based on your example:
WITH HOLLIDAY AS (
                  SELECT DATE '2011-09-12' HOLLIDAY_FROM, DATE '2011-09-26' HOLLIDAY_TILL FROM DUAL
-- end of on-the-fly data sample
SELECT  TO_CHAR(HOLLIDAY_FROM + LEVEL - 1,'IW') week
  FROM  HOLLIDAY
  WHERE TO_CHAR(HOLLIDAY_FROM + LEVEL - 1,'DY','NLS_DATE_LANGUAGE=ENGLISH') NOT IN (
                                                                                    'SAT',
                                                                                    'SUN'
  CONNECT BY HOLLIDAY_FROM + LEVEL - 1 <= HOLLIDAY_TILL
  GROUP BY TO_CHAR(HOLLIDAY_FROM + LEVEL - 1,'IW')
  HAVING COUNT(*) = 5
WE
37
38
SQL> SY.
Edited by: Solomon Yakobson on Sep 19, 2011 12:14 PM

Similar Messages

  • For an Org Unit, how do we get all Reporting Org units (Also employees reporting to the sub org unit) & Employees ?

    Hi Experts,
    I have a very common requirement in SAP HCM ABAP development.
    For an Org Unit, how do we get all Reporting Org units(Also employees reporting to the sub org unit) & Employees ?
    I have tried using RH_STRUC_GET_MULTIPLE_ROOTS and RHPH_STRUCTURE_READ, but the evaluation path is insufficient to get all objects under it. I tried with both O-S-P and O-O-S-P evaluation paths and as per some constraints, I can’t create a customized evaluation path for a reason.
    I am using PNPCE database for user selection screen and user would be advising the Org unit. I even referred the standard transaction ‘S_AHR_61016495’ which is using PCH logical database.
    I would really appreciate if anyone could provide a solution for this. (Rewards guranteed )
    Kindly help.
    Thank you.
    Regards,
    Mahesh Konade

    Hi Alexandre,
    Although I could not respond in time, thank you so much for your prompt reply.
    I had used the same RHPH_STRUCTURE_READ and passed the appropriate values to it, but it did not populate the required results. I cross checked the results manually, may be some relations issue. But later I tried using RH_STRUC_GET_MULTIPLE_ROOTS and it worked fine.
    Meanwhile I had done a workaround with PCH and RH_STRUC_GET and it served the purpose of getting all the Org units, it’s reporting sub-org-units, positions and persons (The deepest structure from the root org unit advised on selection screen).
    The solution I used is, I captured the org-units advised on selection screen by user using PCH logical database and then by looping on sub-org units reporting to the main org-unit I populated related positions and persons holding them and assigned it to the PNPCE logical database.
    Thank you so much for the help.
    Regards,
    Mahesh Konade

  • I am running OS10.6.8 and have a mail box duplication. I use gmail and when I open my mail I have both the Apple Mail and another set of boxes for Gmail. Both get all mail and when I delete from one, it deletes from the other. How can I get rid of the dup

    I am running OS10.6.8 and have a mail box duplication. I use gmail and when I open my mail I have both the Apple Mail and another set of boxes for Gmail. Both get all mail and when I delete from one, it deletes from the other. How can I get rid of the dup

    Hi,
    According to your descriptioin, I don't think this is system problem, it should be Intel driver problem. It would be contact Intel to confirm this issue whether this is their driver problem.
    Roger Lu
    TechNet Community Support

  • When I use the mirror display on my macbook my icons get all messed up when I unplug it.  How do I fix this?

    When I use the mirror display on my macbook my icons get all messed up when I unplug it.  How do I fix this?

    What level of OS X is installed on your Mac (your profile is incomplete)?
    Barry

  • TS1559 i have problem with my iphone as it is disable and need to get all my data as the phone needs at least 40 years to enable accessing it

    I have problem with my iphone as it is disable and need to get all my data as the phone needs at least 40 years to enable accessing it

    If you have never connected the phone to iTunes and backed it up or used iCloud to backup your data, it is lost at this point.
    The only way to get back into the phone is to restore it.
    ~Lyssa

  • Function Module to get date wise weekly offday of employee

    Hi all,
    Is there any standard function module which imports PERNR and DATE and returns the weekly off dates on the basis of
    the work schedule (IT0007)?
    If there is no such Fn Mo, please let me know what tables to look for to do this.
    <<Text removed by moderator>>
    For your information I have already found function module HRPERSONAL_WORK_SCHEDULE.But it is not returning for entire period (say 01.10.2010-31.10.2010)._
    I have also found table relationship but it is not serving my purpose. Table T552A for monthly work schedule.
    Thanks
    Sourav

    Hi Anand,
    Thanks for your reply.
    This fn mo is returning the first three days(01.10.2010,02.10.2010,03.10.2010).
    Rest days of the month (Oct 2010) are not coming.
    According to display work schedule(transaction PT03) this func module is returning the first row bcoz first row contains
    01.10.2010,02.10.2010,03.10.2010.
    Here is my code snippet.
    DATA: it_ptpsp TYPE STANDARD TABLE OF ptpsp INITIAL SIZE 0,
          wa_ptpsp TYPE ptpsp.
    DATA : gd_warning LIKE sy-subrc.
    CALL FUNCTION 'HR_PERSONAL_WORK_SCHEDULE'
    EXPORTING
      pernr             = '00100007'
      begda             = '20101001'
      endda             = '20101031'
    *          KUG               =
    *          REFRESH           = 'X'
    *          WORKING_HOURS     = 'X'
    *          SWITCH_ACTIV      =
    *          MODIFY_ENTRIES    = 'X'
    *          I0001_I0007_ERROR = '0'
    *          READ_CLUSTER      =
    IMPORTING
      warning_occured   =   gd_warning
    TABLES
    *          I0000             =
    *          I0001             =
    *          I0002             =
    *          I0007             =
    *          I0049             =
    *          I2001             =
    *          I2002             =
    *          I2003             =
      perws             = it_ptpsp   "Stores employees work schedule
    *          I0003             =
    EXCEPTIONS
      error_occured     = 1
      abort_occured     = 2
      OTHERS            = 3.

  • How to get all request from database between two dates in servlets

    I am having a servlet in which i am I accepting two form values i.e 'fromdate' and 'todate' by using req.getParameter(fromdate & todate).
    Now i have to query a table called REQUEST which has 4 columns like req_id, name, createdate and status.
    In the servlet I would like to retrieve all the request during that period say for example. between 1st July to 31stJuly, and then display it on the browser with all req_id(first column in the table) having a hyperlink to another XML file which consists of all the details when a user had send his request in the month of July.
    The output on the browser is preferable in a Table format which has to be created dynamically depending the number of request.
    Kindly let me know how I can proceed with this .
    Thanks,
    Regards,
    Lijoy

    The topic seems a little broad.
    The SQL would look something like
    select req_id, name, createdate, status
    from request
    where createdate > fromdate and <= todate

  • Not able to get all the results if i use "get-spdeletedsite" command

    Hi everyone,
    I am not able to get all the results when I use the below powershell command.
    get-spdeletedsite -limit all
    It is giving me only one site, but infact we have more than 100 deleted sites.
    If I use the normal command like below it is giving the below output
    get-spdeletedsite
    Can any one tell me, how can I get all the deleted sites ?
    Best Regards
    Anil Alladi

    Hi  Anil,
    For the Limit parameter of Get-SPDeletedSite cmdlet, when we specify its value to ALL, it  will return all site collections for the given scope.
    For your scenario, the script “Get-SPDeletedSite –Limit ALL” will return all deleted site collections in your SharePoint environment.
    If you want to get all deleted site, you can export the result to csv as below:
    Get-SPDeletedSite | export-csv out.csv -notypeinformation
    Reference:
    http://technet.microsoft.com/en-us/library/hh286316(v=office.15).aspx
    Best Regards,
    Eric
    Eric Tao
    TechNet Community Support

  • I have a license for all adobe files but recently i had a virus and all my files were deleted.Now when i want to have them back with my redemption code it says that i cannot use it anymore.But my license is not expired.How do i get my files back??

    i have a license for all adobe files but recently i had a virus and all my files were deleted.Now when i want to have them back with my redemption code it says that i cannot use it anymore.But my license is not expired.How do i get my files back??

    Your redemption code was used to acquire an activation code.  The activation code is what you need to use when you want to reinstall/enable the software again.  Check your Adobe account online to see if the number(s) can be found there.

  • I had to do a complete system restore on my computer and now I am having issues getting all my music back. It's telling me that my account is in use with a different user but I'm the only user on my computer. When I go to sync it, it wants to delete all.

    I had to do a complete system restore on my computer and now I am having issues getting all my music back. It's telling me that my account is in use with a different user but I'm the only user on my computer. When I go to sync it, it wants to delete all my music and ringtones. What should I do? I don't want to loose all my items.

    When in recovery mode you can't backup the iPod.
    You will have to restore via iTunes. See:
    iTunes: Restoring iOS software
    To restore from backup see:
    iOS: How to back up
    If you restore from iCloud backup the apps will be automatically downloaded. If you restore from iTunes backup the apps and music have to be in the iTunes library since synced media like apps and music are not included in the backup of the iOS device that iTunes makes.
    You can redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store

  • When I left my former employer, Pollinate Agency, I bought a MacBook Pro with Acrobat Pro (version 9 or possibly 9.5) installed from the company. I recently had a serious computer crash, and needed to get all contents erased. The support provider didn't h

    When I left my former employer, Pollinate Agency, I bought a MacBook Pro with Acrobat Pro (version 9 or possibly 9.5) installed from the company. I recently had a serious computer crash, and needed to get all contents erased. The support provider didn't have my product key, so could not reinstall Acrobat Pro for me. Since then, I have gotten the product key sent to me from my former employer, [ REMOVED ] So I need help in re-downloading, installing and activating the Acrobat Pro software on this computer.

    Please remove the S/N immediately (I can't or would). Never post them online. As for download you can go to http://helpx.adobe.com/acrobat/kb/acrobat-downloads.html on the right panel to get 9 pro. I am not sure there is a MAC version there, but that is the first place to go. If it is the proper version, then please back it up to CD and/or portable HD, not the system HD.

  • I had the Siri app before it was added to all iphones and when Apple added it mine quit working. I deleted mine from my phone but do not see how to get it back. any suggestions?

    I had the Siri app before it was added to all iphones and when Apple added it mine quit working. I deleted mine from my phone but do not see how to get it back. any suggestions?

    bjorth wrote:
    apparently I have just an iphone 4 not 4s, so thank you.
    It does seem rather odd that an app that was acquired thru itunes would quit working once it was incorporated into the device for all users. oh well it was probably free or $.99 when I downloaded it.
    I would think that they were just testing it to see how many people would use it.  But you might want to write a polite letter to Apple requesting a credit for the purchase price of the no longer supported app.  That seems to be the least they could for one of their 'alpha testers'.

  • My daughter recently broke her iphone 4.  We had a spare so we exchanged SIM card.  Now that we are linked in the cloud, I am getting all of her text messages and when I text her i get a text from my  number.  What should i try next?

    My daughter recently broke her iphone 4.  We had a spare so we exchanged SIM card.  Now that we are linked in the cloud, I am getting all of her text messages and when I text her i get a text from my  number.  What should i try next?

    stop using the same Apple ID for iMessage on both phones

  • TS2529 I backed up my Ipone 4s through itunes. however when after I had to restore it to factory settings i then proceeded to restore the backed up files and found that it didn't restore any of my music or apps! is there a way i can get all this back?

    I backed up my Ipone 4s through itunes. however when after I had to restore it to factory settings i then proceeded to restore the backed up files and found that it didn't restore any of my music or apps! is there a way i can get all this back?

    You can redownload iTunes purchases by:
    Downloading past purchases from the App Store, iBookstore, and iTunes Store
    Synced media like apps and music are not included in the backup that iTunes makes.

  • I had my 4S activated at the store, but when I got home to sync up my phone and get all of my contacts, nothing is happening. I backed up my 3GS before switching phones, so it's all on my computer. Any ideas?

    I had my 4S activated at the store, but when I got home to sync up my phone and get all of my contacts, nothing is happening. I backed up my 3GS before switching phones, so it's all on my computer. Any ideas?

    Launch iTunes. From the menu bar click Store / View My Account
    Click: Edit Payment Information
    Make sure you have the correct Security Code.
    Then click: Done
    And try resetting your Apple ID password.  https://iforgot.apple.com/cgi-bin/WebObjects/DSiForgot.woa/wa

Maybe you are looking for