>>Script Language and Platform: Oracle
Generates a online calendar of any month of any year based on values of month/year provided by the user. It runs well for any Oracle system environment.
Author: Luis Claudio Rodrigues da Silveira
/* Generates a online calendar of any month of any year
based on values of month/year provided by the user.
Author : Luis Silveira
Last updated : October 31st, 2003
*/
set echo off
set verify off
set feed off
set pages 0
set lines 80
column week format a80
accept mon prompt ‘Provide the month (0-12) : ‘
accept year prompt ‘Provide the year (format YYYY) : ‘
select decode(marker, 1, ‘—— ‘ ||
substr(rtrim(ltrim(‘&year’)), 1, 1) || ‘ ‘ ||
substr(rtrim(ltrim(‘&year’)), 2, 1) || ‘ ‘ ||
substr(rtrim(ltrim(‘&year’)), 3, 1) || ‘ ‘ ||
substr(rtrim(ltrim(‘&year’)), 4, 1) || ‘ ‘ ||
‘—–‘,
3, ‘ S M T W T F S’,
2,
decode(mon, 1, ‘ J A N U A R Y ‘,
2, ‘ F E B R U A R Y ‘,
3, ‘ M A R C H ‘,
4, ‘ A P R I L ‘,
5, ‘ M A Y ‘,
6, ‘ J U N E ‘,
7, ‘ J U L Y ‘,
8, ‘ A U G U S T ‘,
9, ‘ S E P T E M B E R ‘,
10, ‘ O C T O B E R ‘,
11, ‘ N O V E M B E R ‘,
12, ‘ D E C E M B E R ‘),
4,
decode(weekday, ‘1’, ‘ 1 2 3 4 5 6 7’,
‘2’, ‘ 1 2 3 4 5 6’,
‘3’, ‘ 1 2 3 4 5’,
‘4’, ‘ 1 2 3 4’,
‘5’, ‘ 1 2 3’,
‘6’, ‘ 1 2’,
‘7’, ‘ 1’),
32,
decode(mon, 2,
decode(lastday, ’28’,
decode(weekday, ‘1’, ’28 ‘,
‘2’, ’27 28 ‘,
‘3’, ’26 27 28 ‘,
‘4’, ’25 26 27 28 ‘,
‘5’, ’24 25 26 27 28 ‘,
‘6’, ’23 24 25 26 27 28 ‘,
‘7’, ’23 24 25 26 27 28 ‘),
’29’,
decode(weekday, ‘1’, ’29 ‘,
‘2’, ’28 29 ‘,
‘3’, ’27 28 29 ‘,
‘4’, ’26 27 28 29 ‘,
‘5’, ’25 26 27 28 29 ‘,
‘6’, ’24 25 26 27 28 29 ‘,
‘7’, ’23 24 25 26 27 28 29′)),
decode(lastday, ’31’,
decode(weekday, ‘1’, ’29 30 31 ‘,
‘2’, ’28 29 30 31 ‘,
‘3’, ’27 28 29 30 31 ‘,
‘4’, ’26 27 28 29 30 31 ‘,
‘5’, ’25 26 27 28 29 30 31′,
‘6’, ’24 25 26 27 28 29 30′,
‘7’, ’23 24 25 26 27 28 29′),
decode(weekday, ‘1’, ’29 30 ‘,
‘2’, ’28 29 30 ‘,
‘3’, ’27 28 29 30 ‘,
‘4’, ’26 27 28 29 30 ‘,
‘5’, ’25 26 27 28 29 30 ‘,
‘6’, ’24 25 26 27 28 29 30′,
‘7’, ’23 24 25 26 27 28 29′))),
39,
decode(mon, 2, ‘ ‘,
decode(lastday, ’31’,
decode(weekday, ‘6’, ’31 ‘,
‘7’, ’30 31 ‘,
‘ ‘),
’30’,
decode(weekday, ‘7’, ’30 ‘,
‘ ‘))),
decode(weekday, ‘1’, lpad(to_char(marker – 3), 2) || ‘ ‘ ||
lpad(to_char(marker – 2), 2) || ‘ ‘ ||
lpad(to_char(marker – 1), 2) || ‘ ‘ ||
lpad(to_char(marker), 2) || ‘ ‘ ||
lpad(to_char(marker + 1), 2) || ‘ ‘ ||
lpad(to_char(marker + 2), 2) || ‘ ‘ ||
lpad(to_char(marker + 3), 2),
‘2’, lpad(to_char(marker – 4), 2) || ‘ ‘ ||
lpad(to_char(marker – 3), 2) || ‘ ‘ ||
lpad(to_char(marker – 2), 2) || ‘ ‘ ||
lpad(to_char(marker – 1), 2) || ‘ ‘ ||
lpad(to_char(marker), 2) || ‘ ‘ ||
lpad(to_char(marker + 1), 2) || ‘ ‘ ||
lpad(to_char(marker + 2), 2),
‘3’, lpad(to_char(marker – 5), 2) || ‘ ‘ ||
lpad(to_char(marker – 4), 2) || ‘ ‘ ||
lpad(to_char(marker – 3), 2) || ‘ ‘ ||
lpad(to_char(marker – 2), 2) || ‘ ‘ ||
lpad(to_char(marker – 1), 2) || ‘ ‘ ||
lpad(to_char(marker), 2) || ‘ ‘ ||
lpad(to_char(marker + 1), 2),
‘4’, lpad(to_char(marker – 6), 2) || ‘ ‘ ||
lpad(to_char(marker – 5), 2) || ‘ ‘ ||
lpad(to_char(marker – 4), 2) || ‘ ‘ ||
lpad(to_char(marker – 3), 2) || ‘ ‘ ||
lpad(to_char(marker – 2), 2) || ‘ ‘ ||
lpad(to_char(marker – 1), 2) || ‘ ‘ ||
lpad(to_char(marker), 2),
‘5’, lpad(to_char(marker – 7), 2) || ‘ ‘ ||
lpad(to_char(marker – 6), 2) || ‘ ‘ ||
lpad(to_char(marker – 5), 2) || ‘ ‘ ||
lpad(to_char(marker – 4), 2) || ‘ ‘ ||
lpad(to_char(marker – 3), 2) || ‘ ‘ ||
lpad(to_char(marker – 2), 2) || ‘ ‘ ||
lpad(to_char(marker – 1), 2),
‘6’, lpad(to_char(marker – 8), 2) || ‘ ‘ ||
lpad(to_char(marker – 7), 2) || ‘ ‘ ||
lpad(to_char(marker – 6), 2) || ‘ ‘ ||
lpad(to_char(marker – 5), 2) || ‘ ‘ ||
lpad(to_char(marker – 4), 2) || ‘ ‘ ||
lpad(to_char(marker – 3), 2) || ‘ ‘ ||
lpad(to_char(marker – 2), 2),
‘7’, lpad(to_char(marker – 9), 2) || ‘ ‘ ||
lpad(to_char(marker – 8), 2) || ‘ ‘ ||
lpad(to_char(marker – 7), 2) || ‘ ‘ ||
lpad(to_char(marker – 6), 2) || ‘ ‘ ||
lpad(to_char(marker – 5), 2) || ‘ ‘ ||
lpad(to_char(marker – 4), 2) || ‘ ‘ ||
lpad(to_char(marker – 3), 2))) week
from
(select to_number(‘&mon’) mon,
r marker,
to_char(to_date(’01’ ||
lpad(‘&mon’, 2, ‘0’) || ‘&year’, ‘DDMMYYYY’), ‘D’) weekday,
to_char(last_day(to_date(’01’ ||
lpad(‘&mon’, 2, ‘0’) || ‘&year’, ‘DDMMYYYY’)), ‘DD’) lastday
from
(select r
from
(select rownum r
from all_objects
where rownum < 40)
where r in (1, 2, 3, 4, 11, 18, 25, 32, 39))
order by r)
/
Disclaimer: We hope that the information on these script pages is
valuable to you. Your use of the information contained in these pages,
however, is at your sole risk. All information on these pages is provided
“as -is”, without any warranty, whether express or implied, of its accuracy,
completeness, or fitness for a particular purpose…
Disclaimer Continued
Back to Database Journal Home