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