Purushothaman
Purushothaman

Reputation: 113

How to reduce one year in DateTime using update in mysql

How to reduce one year in the DateTime using update query?

 $result=mysqli_query($con, "UPDATE downloads SET ddtime='DATETIME_ADD('$ddtime', INTERVAL -1 YEAR)' WHERE downfile LIKE 'yark'");

Upvotes: 1

Views: 323

Answers (2)

rAnA bilAl
rAnA bilAl

Reputation: 36

Try this:

$result=mysqli_query($con, "UPDATE downloads SET ddtime= DATE_SUB(ddtime, INTERVAL 1 Year) WHERE downfile LIKE '%yark%'");

Upvotes: 1

dimaninc
dimaninc

Reputation: 850

no quotes, no dollar signes:

UPDATE downloads SET ddtime=DATE_SUB(ddtime, INTERVAL 1 YEAR) WHERE ...

Upvotes: 1

Related Questions