I need to delete data older than 180 days from my agg table
Below delete command doesn't seems to be working
Delete from agg_table where sale_date <= '20231101' - 180
Delete from agg_table where sale_date <= '20231101' - interval'180 days'
I have tried few other options as well but it doesn't seem to work.
Sale_date in of date datatype
The issue with your
DELETEcommand is that you are not correctly calculating the date that is 180 days before '20231101'.you can use
DATE_SUBfunction, here is how query will look like itoh there is one more function which we can use as well which is
DATE_ADD(Subtracting negative days)Note: make sure to update the date format as per your database