I have a MySQL database that contains a bigint column named years_valid_for and a datetime(6) column named completion_date. I need to subtract the year from a bigint column.
For example, years_valid_for is 4 and completion_date is 2023-06-07. I need to subtract 4 years from 2023-06-07 to get 2019-06-07.
Is it possible? If possible, how?
I tried the DATE_SUB function but couldn't achieve the expected result due to a syntax error.
Syntax:- DATE_SUB(date, INTERVAL value interval)
You can do it as follows:
View Demo Here