Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • Home
  • SEARCH
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8488871
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T21:40:12+00:00 2026-06-10T21:40:12+00:00

I am looking for some SQL to determine if the current week is the

  • 0

I am looking for some SQL to determine if the current week is the week that contains the Nth Day of the month.

Example. I want to know if I am in the week that contains the third Friday that will occur this month. Or which week of the month contains the third Friday. Weeks should be defined as starting on a Sunday and ending on a Saturday. So a month that starts on a Saturday would not see it’s Friday until the 4th week, where as a month that starts Sunday – Friday, would see it’s 3rd Friday in the 3rd week of the month.

Not sure if PL/SQL is required for this or not.

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T21:40:14+00:00Added an answer on June 10, 2026 at 9:40 pm

    You can simply generate the date ranges for the weeks that contain the Nth Day of each month, e.g. the 3rd Friday of each month, with a query like this:

    select d - day_of_week AS sunday
          ,d + (7 - day_of_week) AS saturday
    from   (select trunc(sysdate,'YY')+rownum-1 AS d
                  ,to_number(to_char(trunc(sysdate,'YY')+rownum-1,'D'))
                   AS day_of_week
            from dual connect by level <= 366)
    where  to_char(d,'W') = 3
    and    to_char(d,'DY') = 'FRI';
    
    SUNDAY      SATURDAY
    ==========  ==========
    14/01/2012  21/01/2012
    11/02/2012  18/02/2012
    10/03/2012  17/03/2012
    14/04/2012  21/04/2012
    12/05/2012  19/05/2012
    09/06/2012  16/06/2012
    14/07/2012  21/07/2012
    11/08/2012  18/08/2012
    15/09/2012  22/09/2012
    13/10/2012  20/10/2012
    10/11/2012  17/11/2012
    15/12/2012  22/12/2012
    

    EDIT:
    You can create a simple function to check a single date, e.g.:

    CREATE FUNCTION date_in_week_of_nth_day
       (in_date IN DATE
       ,in_week IN NUMBER
       ,in_day  IN VARCHAR2
       ) RETURN CHAR IS
      ret CHAR(1);
    BEGIN
      select 'Y' into ret
      from   (select trunc(in_date,'MM')+rownum-1 AS d
                    ,to_number(to_char(trunc(in_date,'MM')+rownum-1,'D'))
                     AS day_of_week
              from dual connect by level <= 31)
      where  to_char(d,'W') = in_week
      and    to_char(d,'DY') = in_day
      and    :in_date between (d - day_of_week) and (d + (7 - day_of_week));
      RETURN ret;
    EXCEPTION
      WHEN NO_DATA_FOUND THEN
        RETURN 'N';
    END;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm looking for a SQL-statement that sums up some specific values and sorts the
I'm currently looking at some light-weight SQL abstraction modules. My workflow is such that
I'm looking at some legacy SQL that looks like this (the names of the
I'm currently looking for a good (free) tool to do some PL/SQL development on
I am looking into using Lucene.NET after reading some bad reviews of SQL Server's
I am looking for some SQL varchar comparison function like C# string.compare (we can
In the process of looking at my logs from Mongrel, I found some SQL
I'm looking for a suitable client side architecture that will meet some or all
I've heard from some that LINQ to SQL is good for lightweight apps. But
For some time now I'm looking for sample (relational) databases (.SQL) so I can

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.