Talk:Oracle Row Generator Techniques

From Oracle FAQ
Jump to: navigation, search

How to find the same day of a month in the table date values.

I have a table with date values for the next 10 years. Against each date there is a flat which will be updated if the date matches a requirement.

The Requirement is to find the same day of a month in all years in the table. e.g 2nd Sunday of October in current year and all the years stored in the table and update the flag to 1.

Currently I am using this:

UPDATE FILTERCALENDAR SET YEAR_WINDOW=1 WHERE c_date = NEXT_DAY( TO_DATE('OCT-2013','MON-YYYY'), 'SUNDAY') + (2-1)*7;

As this is only for the current year. Can anyone suggest how can that be achieve for every year saved in the database. Currently the database table have 10 years in it.

Can Any one help me please.

-------------------
Wiki is not the place to post a question but new page or comment on page.
Try to post it on Forum: http://www.orafaq.com/forum/i/102589/ without forget to before read OraFAQ Forum Guide (http://www.orafaq.com/forum/t/88153/0/) and "How to use [code] tags" topic (http://www.orafaq.com/forum/t/171557/102589/) and make your code easier to read.
With any SQL or PL/SQL question, please, Post a working Test case: create table and insert statements along with the result you want with these data then we will be able work with your table and data. Explain with words and sentences the rules that lead to this result.
Michel Cadot (talk) 07:46, 19 February 2013 (CET)