DBAsupport.com Forums - Powered by vBulletin
Results 1 to 3 of 3

Thread: Last Friday of Month?

Hybrid View

  1. #1
    Join Date
    Apr 2000
    Location
    Johannesburg, Gauteng, ZA
    Posts
    6

    Question

    Hi There, how Do I figure out the YYYY-MM-DD of the last Friday of a Given YYYY-MM, or any similiar datemask query? (first Monday of month, etc...)

    Tnx!

  2. #2
    Join Date
    Apr 2000
    Location
    Johannesburg, Gauteng, ZA
    Posts
    6
    Almost like next_day but perhaps last_day ?

  3. #3
    Join Date
    Apr 2000
    Location
    Johannesburg, Gauteng, ZA
    Posts
    6

    Solution

    create or replace function last_fri (P_yyyydd varchar2) return varchar2 is
    v_date date;
    begin
    select next_day(last_day(to_date(P_yyyydd,'YYYY-MM')) - 7, 'FRIDAY') into v_date from dual;
    return (v_date);
    end;
    /
    show errors;

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  


Click Here to Expand Forum to Full Width