I am trying to add a year to a date going into a SQL database from PHP. I have tried DATEADD(Year,1,NOW()) And various other forms but can’t seem to get it to add a year onto it in SQL.
JavaScript
x
<?php
require ('includes/connect_db.php');
$q = "UPDATE users SET subdate = NOW() WHERE username = '{$_SESSION[username]}'";
$r = @mysqli_query ( $link, $q ) ;
# Close database connection.
# mysqli_close($link);
?>
Thank you very very much!
Advertisement
Answer
You are attempting SQL Server syntax in MySQL.
In MySQL, you would simply do:
JavaScript
now() + interval 1 year
Or:
JavaScript
date_add(now(), interval 1 year)