Restrict the number of records generated to the number of days in a particular year by getting the "day of year" of December 31st:
to_char(to_date('3112'||:year,'ddmmyyyy'),'ddd')
.Convert the record number (
level
) back to a date: to_date(level||'.'||:year,'ddd.yyyy')
.I use a bind variable in the example below instead of a substitution variable for no other reason than to have an example online :)
-- define a bind variable for the year
variable year number
-- assign a year to the bind variable
execute :year := 2006
-- select all days of the year
select to_date(level||'.'||:year,'ddd.yyyy') day
from dual
connect by level
<= to_number
(to_char
(to_date('3112'||:year,'ddmmyyyy')
,'ddd'
)
)
/
No comments:
Post a Comment