comparing the date with 11 months

Database
Enthusiast

comparing the date with 11 months

Hi,

I have a table with the date column.

create table driver
(
insert_dt DATE format 'yyyy-mm-dd'
)

I have to delete the records from this table which are older than 11 months based on insert_dt column.

Like .. delete from table driver where insert_dt > (11 months older ).

Can you please help me to complete this SQL. Thanks in advance

2 REPLIES
Senior Apprentice

Re: comparing the date with 11 months

Hi Rahul,
i didn't understand exactly what you want, but it looks like:
delete from table driver where insert_dt > add_months(insert_dt, -11)

Of course this will delete all the rows, so you probably want to "delete from another table"
or "older than 11 months compared to today":
where insert_dt > add_months(current_date, -11)

Dieter
Enthusiast

Re: comparing the date with 11 months

Thanks Dieter!

Your answer solved my question.

- Rahul