Format Date in MySQL

2

My problem is that I want to add a date column in this format 2016-08-13 Exactly in this Order I achieve this:

 DATE_FORMAT(NOW(),'%y-%m-%d')

but now I need the same format but adding 30 days something like that but I have no idea

DATE_FORMAT(NOW(),'%y-%m-%d')+30

the detail is that when I make the +30 symbol I get this Subject how can I solve that?

    
asked by Juan Carlos Villamizar Alvarez 14.08.2016 в 01:14
source

2 answers

2

Use Interval with the number of days:

DATE_FORMAT(NOW() + INTERVAL 30 DAY,'%y-%m-%d')

or you can use the DATE_ADD () function:

DATE_FORMAT(DATE_ADD(NOW(), INTERVAL 30 DAY), '%y-%m-%d')
    
answered by 14.08.2016 / 01:26
source
1

This worked for me in an opportunity to add days to a date:

$fecha = date('Y-m-j');<br>
$nuevafecha = strtotime ( '+10 day' , strtotime ( $fecha ) ) ;  
$nuevafecha = date ( 'Y-m-j' , $nuevafecha );<br>
echo $nuevafecha;
    
answered by 14.08.2016 в 18:09