Home » SQL & PL/SQL » SQL & PL/SQL » How to display Last Day In Week Indicate As Y or N as input is start date and end date (Windows )
How to display Last Day In Week Indicate As Y or N as input is start date and end date [message #610763] Mon, 24 March 2014 03:34 Go to next message
spatil522@gmail.com
Messages: 1
Registered: March 2014
Location: Pune
Junior Member
How to display Last Day In Week Indicate As Y or N as input is start date and end date
Re: How to display Last Day In Week Indicate As Y or N as input is start date and end date [message #610766 is a reply to message #610763] Mon, 24 March 2014 03:44 Go to previous message
Littlefoot
Messages: 21808
Registered: June 2005
Location: Croatia, Europe
Senior Member
Account Moderator
Here, where I live, the last day in a week is Sunday and its "number" is 7. Therefore, this is how I can distinguish whether certain date is (or is not) the last day in a week ("indicator" shows Y if it is):
SQL> with dates as
  2    (select trunc(sysdate, 'mm') + level - 1 d_date
  3     from dual
  4     connect by level < 15
  5    )
  6  select d_date,
  7    to_char(d_date, 'day') d_day,
  8    to_char(d_date, 'd') n_day,
  9    decode(to_char(d_date, 'd'), '7', 'Y', 'N') indicator
 10  from dates;

D_DATE   D_DAY     N I
-------- --------- - -
01.03.14 saturday  6 N
02.03.14 sunday    7 Y
03.03.14 monday    1 N
04.03.14 tuesday   2 N
05.03.14 wednesday 3 N
06.03.14 thursday  4 N
07.03.14 friday    5 N
08.03.14 saturday  6 N
09.03.14 sunday    7 Y
10.03.14 monday    1 N
11.03.14 tuesday   2 N
12.03.14 wednesday 3 N
13.03.14 thursday  4 N
14.03.14 friday    5 N

14 rows selected.

SQL>
Could you adjust it according to your needs?

[EDIT: forgot to switch to English]

[Updated on: Mon, 24 March 2014 03:47]

Report message to a moderator

Previous Topic: Time Elapsed
Next Topic: Please help for ORA-01416: two tables cannot be outer-joined to each other
Goto Forum:
  


Current Time: Thu Apr 25 10:11:18 CDT 2024