Find 3rd friday of the month for a given date

how to find out 3rd friday of the month for a given date? I can always pass the first day of the month as input
eg, input date is 01-JAN-09. need to get the 3rd friday 16-JAN-09 (Jan has 5 fridays 02, 09, 16,23,30)
input date : 01-feb-09, need to get 20-feb-09
Edited by: user520824 on Apr 1, 2009 12:30 PM

NLS independent solution:
SELECT  DT,
        TO_CHAR(DT,'FMDay') day,
        CASE
          WHEN TRUNC(TRUNC(DT,'MM') + 7,'IW') - 3 < TRUNC(DT,'MM') THEN TRUNC(TRUNC(DT,'MM') + 7,'IW') + 18
          ELSE TRUNC(TRUNC(DT,'MM') + 7,'IW') + 11
        END THIRD_FRIDAY_OF_THE_MONTH
  FROM  (
         SELECT  TO_DATE(LEVEL || '/2009','MM/YYYY') DT
           FROM  DUAL
           CONNECT BY LEVEL < 13
DT        DAY       THIRD_FRI
01-JAN-09 Thursday  16-JAN-09
01-FEB-09 Sunday    20-FEB-09
01-MAR-09 Sunday    20-MAR-09
01-APR-09 Wednesday 17-APR-09
01-MAY-09 Friday    15-MAY-09
01-JUN-09 Monday    19-JUN-09
01-JUL-09 Wednesday 17-JUL-09
01-AUG-09 Saturday  21-AUG-09
01-SEP-09 Tuesday   18-SEP-09
01-OCT-09 Thursday  16-OCT-09
01-NOV-09 Sunday    20-NOV-09
DT        DAY       THIRD_FRI
01-DEC-09 Tuesday   18-DEC-09
12 rows selected.
SQL> SY.

Similar Messages

  • Find the 'DAY' for a given 'DATE'

    Hi Folks,
    I need a help regarding finding the day for a given date.
    My requirement is that..,
             If I enter a date using 'parameters', it should write the 'day' for the corresponding date.
    To be more specific.....,
    if I enter date as ' 07/15/2008 ' it should return me  the day as 'Tuesday'.
    Regards,
    Naveen G

    HI,
    FM LIST WITH RESPECT TO DAY, WEEK, AND MONTH.
    CALCULATE_DATE : Calculates the future date based on the input .
    DATE_TO_DAY : Returns the Day for the entered date.
    DATE_COMPUTE_DAY : Returns weekday for a date
    DATE_GET_WEEK : Returns week for a date
    RP_CALC_DATE_IN_INTERVAL : Add days / months to a date
    MONTHS_BETWEEN_TWO_DATES : To get the number of months between the two dates.
    END_OF_MONTH_DETERMINE_2 : Determines the End of a Month.
    HR_HK_DIFF_BT_2_DATES : Find the difference between two dates in years, months and days.
    FIMA_DAYS_AND_MONTHS_AND_YEARS : Find the difference between two dates in years, months and days.
    MONTH_NAMES_GET : Get the names of the month
    WEEK_GET_FIRST_DAY : Get the first day of the week
    HRGPBS_HESA_DATE_FORMAT : Format the date in dd/mm/yyyy format
    SD_CALC_DURATION_FROM_DATETIME : Find the difference between two date/time and report the difference in hours
    L_MC_TIME_DIFFERENCE : Find the time difference between two date/time
    HR_99S_INTERVAL_BETWEEN_DATES : Difference between two dates in days, weeks, months
    LAST_DAY_OF_MONTHS : Returns the last day of the month
    DATE_CHECK_PLAUSIBILITY :Check for the invalid date.
    Reward points if useful,
    siri

  • How to get start date of the period for a given date from cube

    I have a situation where i need to find the start day of the period for a given date. is there a way to know that. i want to use that in my report. i enter the date from my report(i have date parameter), depends on the date, i want to display the start day
    of the period. how can i write expression for that in my report?
    ram

    Hi ramprasad74,
    According to your description, you are using Analysis Services as a data source for the report, the cube has hierarchy: Fyear, FQuarter, FPeriod, fweek, Fdate. You want to add a date parameter to the report, after you changed value of the parameter, the
    report will return the first day of FPeriod.
    To achieve your goal, we need to add a parameter to the report, then use the parameter in mdx query. For detail information, please refer to the following steps:
    In the Report Data pane, right-click on a dataset created from a SQL Server Analysis Services data source type, and then click Query. The MDX query designer opens in Design mode.
    On the toolbar, click Design to toggle to Query mode.
    On the MDX query designer toolbar, click Query Parameters symbol. The Query Parameters dialog box opens.
    In the Parameter column, click <Enter Parameter>, and then type the name of a parameter.
    In the Dimension column, choose a value from the drop-down list.
    In the Hierarchy column, choose a value from the drop-down list.
    In the Default column, from the drop-down list, select a single value.
    Click OK. 
    In query designer dialog box, type the mdx query like below:
    with member [Measures].[FirstChild]
    as
    [Date].[Fiscal].currentmember.parent.firstchild.name
    select {[Measures].[FirstChild]} on 0,
    [Date].[Fiscal].[Date].members on 1
    from
    ( SELECT ( STRTOSET(@ParameterName, CONSTRAINED) ) on 0
    from
    [Cube]
    Here are relevant threads you can reference:
    https://social.msdn.microsoft.com/forums/sqlserver/en-US/c7146ac3-40ea-4d53-b321-c707aebbd405/how-to-pass-date-parameter-to-mdx-query
    https://social.msdn.microsoft.com/forums/sqlserver/en-US/fd12a865-bc90-4a65-af42-ce38a8cfa29b/pass-date-time-parameter-to-mdx-query-ssrs
    If you have any more questions, please feel free to ask.
    Thanks,
    Wendy Fu
    If you have any feedback on our support, please click
    here.

  • How to Call Center Opens at a diffrent times 1st and 3rd Tue. of the Month

    Hello all,
    I'm new to UCCX and doing my best to understand scripting. I've created a script that's is normally open 7am to 12pm closed from 12pm to 1pm for lunch then open from 1pm to 5pm then closed again until 7am.
    Now every 1st and 3rd Thursday of the month they open at 9am instead of 7am.
    How would like script something like this? Is this possible?
    Thanks in advance for the help.
    We are running UCCX version 8.5 and using the IPPA.

    Here's a solution that works with Enhanced.
    The solution is simple.  If today's Day of Week (DoW) is equal to the target DoW, then we jump backwards in time by one week, and if we're still in the same month, we repeat that process over and over again, until we have stepped back so far, we step into the previous month.  All along the way, keeping track of how many times we were able to jump back in the same month.  This becomes our instance counter and what we check to see if we are on the correct instance of the target DoW.
    Subflow Script
    Variables
    boolean is_matched = false
    Date today = d[now]
    Date date_crawler = d[now]
    int target_dow = 0
    int target_instance = 0
    int instance_counter = 0
    Script: system-date-instances.aef
    StartLABEL0:If (date_crawler.dow == target_dow) Then  True    Increment instance_counter    Do date_crawler.setDate(date_crawler.date - 7)    If (date_crawler.month == today.month) Then      True        Goto LABEL0      False  FalseSet is_matched = instance_counter == target_instanceEnd
    Caller Script
    Variables
    boolean is_third_thursday = false
    Script - main-aa.aef
    Start...the intro to your script.../* You will need to pass in two integers as input parameters: target_dow and target_instance *//* taget_dow can be 1 - 7 (Sunday - Saturday) *//* target_instance would be a number representing which DoW you are interested in *//* E.g., If I wanted to know if today is the third thursday in the month I would pass in: *//* target_dow = 5 and target_instance = 3 *//* You will need to get back one boolean as an output parameter: is_matched */is_third_thursday = Call Subflow(SCRIPT[system-date-instances.aef], is_matched)If (is_third_thursday)  True    ...use modified business hours...  False    ...use regular business hours......the rest of your script...End
    Anthony Holloway
    Please use the star ratings to help drive great content to the top of searches.
    Tags: first, second, third, fourth, sunday, monday, tuesday, wednesday, thursday, friday, saturday
    Message was edited by: Anthony Holloway - Adding tags

  • How to find the Day on a Week for any given Date

    Hi..... I need your help to find out the Day on a Week for any given Date .
    Say if the Date is 31/12/2009 , what would be the Day on a Week for this Date.
    Are there any fucntions available to determine the same?
    Please let me know....Thanks in Advance
    Regards
    Smita

    Hi ,
    You can using the following peice of code to get the Day of a Week for the given date :
    Calendar now = Calendar.getInstance();   
    System.out.println("Current date : " + (now.get(Calendar.MONTH) + 1)  
         + "-" + now.get(Calendar.DATE) + "-" + now.get(Calendar.YEAR));
    //create an array of days  
    //Day_OF_WEEK starts from 1 while array index starts from 0        
    String[] strDays = new String[]{"Sunday",  "Monday", "Tuesday", "Wednesday",  "Thusday",   "Friday",  "Saturday" };   
    String day_of_week = strDays[now.get(Calendar.DAY_OF_WEEK) - 1];     
    System.out.println("Current day is : " + strDays[now.get(Calendar.DAY_OF_WEEK) - 1]  );
    Edited by: Ritushree Saha on Jun 4, 2009 1:09 PM

  • How do I add a recurring event to repeat on the fifth recurring day of the month, for example, an event that only happen on the fifth Sunday of the month for those months that have a fifth Sunday?

    How do I add a recurring event to repeat on the fifth recurring day of the month, for example, an event that only happen on the fifth Sunday of the month for those months that have a fifth Sunday?

    Create one on the first Tuesday, select repeat/monthly and take the option at the bottom.

  • How to find out the infoProvider for a given dimension table?

    Experts:
    In RSA1, I want to find out the infoProvider for a given dimension table.
    But I am not sure how to display the tables linked to a given infoProvider.
    Could you provide a way to display all tables linked to a given infoProvider?
    Thanks a lot!

    See, The dimension table starts with Dcubename1 and incremental Dcubename2 .... so on
    Ex.ZSD_C01 is your cube name
    Dim tables starts for this is /BIC/DZSD_C011 /BIC/DZSD_C012 ...
    Goto - LISTSCHEMA  - derive cube name from given dim table and enter cube name  - execute - will show you all the tables

  • Plant and Profit center wise Turnover and  gross profit for the Month for s

    Hi
    We need a report Plant and Profit center wise Turnover and
    gross profit for the Month for selected month and GL's
    We are using new GL. but our bi system old version.
    SAP_BW -- 7                      Patch:SAPKW70015
    BI_CONT - 703                    Patch:SAPKIBIIP7
    Do you have any idea or experiences which data source and data target required to full fill this requirement?
    Thanks
    Ramana P

    Hi
    You need to check if you really the report Plant wise and if yes, then check if the Accounting Transactions are maintained at Plant Level in your source system i.e. in R3.
    Ideally it should be Business area or Functional Area or Controlling area which are maintained in Accounting Transactions. You will also the relevant details for these Characterisitics + Profit Center in the NEW GL Accounting data sources.
    Cheers
    Umesh

  • I cannot find how to change the language for labels in a quiz

    I cannot find how to change the language for labels in a quiz

    You have to be aware that this will only change labels if you edit before adding quiz slides: Preferences, Quiz, Default Labels. You will have to edit the labels, choosing another language will not change them automatically.

  • HT2493 I have a problem with the 3rd step of the Guide for personalizing icons

    I have a problem with the 3rd step of the Guide for personalizing icons: when i click on the little image of the icon in the Get Info window it doesn't come out any command to choose in order to copy it.. is that a problem with mountain lion? where is the interactive icon to click on in the Get Info window?

    Thanks guys! I was expecting to se a window when it was even easier!:P
    Thanks for helping!
    Bye!

  • Where can I find a copy of the eula for Adobe Acrobat XI?

    Where can I find a copy of the eula for Adobe Acrobat XI?
    The eula does not come up for inspection when you install the software.

    http://www.adobe.com/legal/licenses-terms.html

  • Why can't I find any games in the Store for Ipod Classic?

    Why can't I find any games in the Store for the Ipod Classic?

    Hard to say, as you provide almost no information..  I would guess that you are looking in the wrong place.

  • How to get period date of for a given month from a given date in mdx for SSRS report (mm/dd/yyyy)

    I have a situation,  where i need to write expression Period to date(PTD). i want to know how to get the period date. i want you to help in writing Period date or else is there any function to get period date for a given date(the  date is given
    from the parameter dynamically) in MDX for SSRS report
    ram

    Hi ram,
    Per my understanding that you want to get the period date based on the month selected and the given date, right?
    Could you please provide details information below to help us better understanding your requirements, thus we will be more effective to provide an solution:
    What is the format of the period date you want to get, is this date in the DB and you want to filter it based on the month and the given Date?
    Did the month and given date are two parameters in the report? if possible, could you please provide some sample data in the DB and also the snapshot of the report structure
    I assume you want to get the period date(mm/dd/yyy) between the select month(e.g:Feb) and the given date (10/1/2014) and you should get the date between(02/01/2014-10/1/2014).
    If so,and you also have two parameter "Month","EndDate"(EndDate is the given date), please reference to details information below:
    You can create an new parameter "BeginDate" (Date/Time) which is the begin date of the period, you can use the expression to get the value based on the value of the month and the year value from the given date,finally hide this parameter:
    Specify the available value:
    Label:=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value)
    Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
    Specify the default Value:
    Value:=CDate(=Parameters!Month.Value &"/01/"& DatePart("yyyy",Parameters!EndDate.Value))
    Add filter to the dataset as below:
    Preview you will get all the date in the given Period:
    If you still have any problem, please feel free to ask.
    Regards
    Vicky Liu

  • Get the Stock for a given Material no

    Hi,
         I'm an ABAP consultant, new to MM.
         I have a requirement - For a given Production Order I have to find the Material and respective BOM Explosion. Once that is done I have to get the Stock for those Materials [Child Materials].
    I have used AUFK and AFPO to get the material from the Production Order and Used MAST table to get the other details and passed it to FM - 'CS_BOM_EXPL_MAT_V2' - This gives me the Child materials.
    Now I want to know how can I find the Stock for a given Material. I want to get the Overall Unrestricted stock. Which Table do I have to use. Is there any standard Function Module [FM] or BAPI to get it.
    Please help.
    Thanks & Regards,
    Ashish

    I have gone through  the MARD table. I want to confirm - for a Material no there are more than 1 plant and for each plant there are more than storage location. So I have to add the Unrestricted Stock of all those to get the Full Unrestricted Stock.
    Please refer Transaction MMBE - I have to use that output.

  • How to get the week number for a given date?

    hi guys,
    what is coding to get the week number for a given date?
    For example, 1/1/05 is week 1. then 8/1/05 is week 2.

    The second parameter to pass to the method is supposed to be one of the month constants JANUARY - DECEMBER. It happens to be that their numerical values are 0-11, not 1-12, so your "12" refers to the "13th" month of the year.
    givenDate = new GregorianCalendar(2003, Calendar.DECEMBER, 31);
    If you want to construct dates and times from strings like you seem to be, look into SimpleDateFormat http://javaalmanac.com/egs/java.text/ParseTime.html
    (even still I got WEEK_OF_YEAR as 1 which is true but not really what I expected, excuse my previous reply but I wanted to check the facts before posting this)

Maybe you are looking for

  • Keyboard lights on Macbook Not Working Running Windows 7

    Hello Any idea how to get my keyboard lights to work when I boot up windows 7 using bootcamp ? Thanks

  • Server PHP GD support

    Hello, I know this issue has been a subject around for awhile..  I am well aware their are many subjects online abut how to resolve this.. However, I belive my concern may be a little different.. I am coming from a better understanding of IIS.. I'll

  • Will my Microsoft Word files open in iWorks?

    Recently upgraded my MacBookPro . . . On my old one I used Microsoft Word for word processing.  if I install iWorks, will I be able to open my old Word files in it?

  • Report .rdf owner , creator and modifier

    I changed .rdf to .rex and from the rex file under "TOOL_MODULE" I can tell who is the owner, creator or modifier From where to find the same information from the .rdf itself ?

  • I have upgrade the system to Mountain Lion, no sound after

    the sound system stopped working after the upgrade, what can I do? the internal speaker and earphones dont work anymore, cannot even adjust the speaker volume...shows like this: Thanks a lot for any help!  system version: 10.8