I want to add 30 days to mysql date row

后端 未结 4 960
故里飘歌
故里飘歌 2021-01-27 02:50

My Code.

    

        
相关标签:
4条回答
  • 2021-01-27 03:06

    Try this:

        $sql="INSERT INTO users (first_name, last_name, web, email, date)
        VALUES ('$Fname', '$Lname', '$web', '$email', '$date', DATE_ADD(NOW(), INTERVAL 30 DAY))";
    
        $result = mysql_query($sql); 
    
    >> you are adding date after query executes, but do the same when query executes.
    
    • Thanks

    0 讨论(0)
  • 2021-01-27 03:09

    Here is the part you need to change

    $sql="INSERT INTO users (first_name, last_name, web, email, date)
    VALUES ('$Fname', '$Lname', '$web', '$email', '$date', NOW() + INTERVAL 30 DAY)";
    
    0 讨论(0)
  • 2021-01-27 03:14

    Use the following query :

     $sql="INSERT INTO users (first_name, last_name, web, email, date)
        VALUES ('$Fname', '$Lname', '$web', '$email',DATE_ADD('$date', INTERVAL 30 day)  , NOW())";
    
    0 讨论(0)
  • 2021-01-27 03:16

    Do like this...

    $sql="INSERT INTO `users` (`first_name`, `last_name`, `web`, `email`, `date`)
        VALUES ('$Fname', '$Lname', '$web', '$email', DATE_ADD('$date', INTERVAL 30 DAY))";
    
    0 讨论(0)
提交回复
热议问题