Search code examples
mysqldatabasedateadd

Mysql- Add days to date with different format


I have to add days in my date column and I have date format as m/d/Y. For example, 06/10/2017 I have tried SELECT DATE_FORMAT(DATE_ADD('06/10/2017',INTERVAL 14 DAY), '%m/%d/%Y'); but it is not giving me any output


Solution

  • Use str_to_date:

    SELECT DATE_ADD(STR_TO_DATE('06/10/2017', '%m/%d/%Y'),INTERVAL 14 DAY);
    

    Based on your comment, use date_format to reformat it as you did in your post:

    SELECT DATE_FORMAT(DATE_ADD(STR_TO_DATE('06/10/2017', '%m/%d/%Y'),
                                INTERVAL 14 DAY), '%m/%d/%Y');