Day of the week: Difference between revisions

Added SQL solution
(Added SQL solution)
Line 4,111:
25-Dec-2112
25-Dec-2118</pre>
 
=={{header|SQL}}==
 
SQL has good support for date functions; care must be taken with NLS settings (globalization support), in the code below the date format language is passed in as an argument to the relevant function.
 
<lang sql>select extract(year from dt) as year_with_xmas_on_sunday
from (
select add_months(date '2008-12-25', 12 * (level - 1)) as dt
from dual
connect by level <= 2121 - 2008 + 1
)
where to_char(dt, 'Dy', 'nls_date_language=English') = 'Sun'
order by 1
;</lang>
 
 
{{out}}
<pre>
YEAR_WITH_XMAS_ON_SUNDAY
------------------------
2011
2016
2022
2033
2039
2044
2050
2061
2067
2072
2078
2089
2095
2101
2107
2112
2118
 
17 rows selected.</pre>
 
=={{header|Stata}}==
Anonymous user