converting interger to date format and comparing with current_date

Database
Enthusiast

converting interger to date format and comparing with current_date

i have a column accounting_month in interger format(200,904).

the initail 4 number is year 2009 and last 2 are month 04.

i want to convert it into date format and then i want it to compare with current date.

if the cuurent month and year are same as accounting_month month and year then flag cloumn(new column) value sholud be 1 or else 0.

example today date 10/22/2013(mm/dd/yyyy) and value from accounting month is 201310(yyyymm) then flag value should be 1 or else 0.

please help me.

its v urgent

2 REPLIES
Senior Apprentice

Re: converting interger to date format and comparing with current_date

case 
when accounting_month =
extract(year from current_date) * 100
+ extract(month from current_date)
then 1
else 0
end

There's a slighly shorter version, but it's based on the internal storage of a date and thus not as easy to understand:

case 
when accounting_month = (current_date / 100) + 190000
then 1
else 0
end

Dieter

Enthusiast

Re: converting interger to date format and comparing with current_date

thanks a lot dieter