Results 1 to 3 of 3
  1. #1
    Join Date
    Jul 2003
    Posts
    13

    Unanswered: Get the sepcific dates....

    Hi,
    Is there any way to find last sunday's date using oracle sql. I can get it using the function 'to_char(next_day(sysdate-6,'SUNDAY'), 'MM/DD/YYYY')' but I dont find it more logical to use.
    Can anyone help me if there is any fuction similar to 'nextday'(like 'lastday' or so) in oracle to get last sunday's date and other dates of this week.

    thanks,
    sma

  2. #2
    Join Date
    May 2004
    Location
    Dominican Republic
    Posts
    721
    Why you 'dont find it more logical to use' anymore ?

  3. #3
    Join Date
    Sep 2002
    Location
    UK
    Posts
    5,171
    Provided Answers: 1
    Why not create your own? :-
    Code:
    SQL> create or replace function previous_day (p_date date, p_day varchar2) return date
      2  is
      3  begin
      4    return next_day(p_date-7, p_day);
      5  end;
      6  /
    
    Function created.
    
    SQL> select sysdate-rownum+5, previous_day(sysdate-rownum+5,'SUN') from emp
      2  order by 1;
    
    SYSDATE-ROW PREVIOUS_DA
    ----------- -----------
    22-MAR-2006 19-MAR-2006
    23-MAR-2006 19-MAR-2006
    24-MAR-2006 19-MAR-2006
    25-MAR-2006 19-MAR-2006
    26-MAR-2006 26-MAR-2006
    27-MAR-2006 26-MAR-2006
    28-MAR-2006 26-MAR-2006
    29-MAR-2006 26-MAR-2006
    30-MAR-2006 26-MAR-2006
    31-MAR-2006 26-MAR-2006
    01-APR-2006 26-MAR-2006
    02-APR-2006 02-APR-2006
    03-APR-2006 02-APR-2006
    04-APR-2006 02-APR-2006

Posting Permissions

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