Add date with int

4

I'm trying to make a sum of days, reported in a int field, with a date field using SQL. I tested the form below, but it adds up to the day, but ignores month and year. Is there any way to do this sum?

SELECT DATE_FORMAT(ocorrencias.dt_fechamento, '%d-%m-%Y')+50 as calendario from ocorrencias
    
asked by anonymous 22.03.2016 / 21:44

2 answers

7

Attempts to use the command DATE_ADD(ocorrencias.dt_fechamento, INTERVAL 50 DAY)

Example: SELECT DATE_FORMAT(DATE_ADD(expiry_date,INTERVAL 3 DAY), '%d %m %Y' )

    
22.03.2016 / 21:48
3

Use the date_add() function of MySQL

SELECT DATE_FORMAT(date_add(ocorrencias.dt_fechamento, INTERVAL 50 day), '%d-%m-%Y') 
       as calendario FROM ocorrencias

Simple example:

SELECT  date_add(now(), INTERVAL 50 day)
    
22.03.2016 / 21:49