Year to Date flag in Date Dimension

I have a date dimension (date Table) and I want to add two columns to it:  Current YTD and Previous YTD.  This column is a char(1) data type that will store an 'X' when the dates are between the first of the year and the current date for the current YTD.

The previous YTD will be the same dates but in the previous year.  What is the Oracle sql for both of these columns that will be updated daily?
Who is Participating?
update mytable
set c1='X'
where to_char(c_date,'YYYY')=to_char(sysdate,'YYYY');

update mytable
set c1= c_date - 365 ;   --  how about 366 ?

update mytable
set c1= add_months( c_date, - 12) ;   --  how about 2012-2-29 ?

Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.