Date expiring from the datetime (datetime) - MYSQL

0

The field is of type datetime, such as displaying the date for here 30 days from the date you registered, eg:

<?php

// 'data_cad' = '2018-03-01 01:52:00'

$instrucao = "SELECT 
                'user_id',
                'status',
                'user_nome',
                'data_cad' 
              FROM 
                'usuario' 
              ORDER BY 
                'user_nome' 
                  ASC 
              LIMIT 1";

$query = mysqli_query($conn, $instrucao);

$arr = mysqli_fetch_array($query);

?>

If the registration date is 01/03/2018 ('2018-03-01 01:52:00'), the expiration date will be 03/31/2018. But how to tell the date by making mysql understand that the year has only 28 days in February, 31 days in March, so the date needs to register to expire in 30 days.

Thank you.

    
asked by anonymous 02.02.2018 / 07:05

1 answer

1

I resolved using DATE_ADD with INTERVAL X DAY

"SELECT DATE_ADD('2018-12-20 01:52:00', INTERVAL 30 DAY);"
    
02.02.2018 / 07:18