Page 1 of 1

Query using date_add and date_format

Posted: Tue Nov 06, 2012 3:06 pm
by Alpal
Hi
Am building an invoicing system in a small sporting associations website.

Have this query, it works fine.
SELECT date_format( inv_date, '%b %e, %Y' ) AS issuedate, DATE_ADD( inv_date, INTERVAL 14 DAY ) AS duedate, inv_id, inv_date
FROM inv_to

inv_date is a DATE column in the table.

What I would like to do is put these 2 parts of the query together so I have a "Due Date" 14 days after the "Issue Date" that is reformatted
"date_format( inv_date, '%b %e, %Y' ) --------DATE_ADD( inv_date, INTERVAL 14 DAY ) AS duedate

Hope this makes sense.
As always, thanks in advance for any assistance you can offer

Re: Query using date_add and date_format

Posted: Tue Nov 06, 2012 5:07 pm
by requinix
Alpal wrote:What I would like to do is put these 2 parts of the query together so I have a "Due Date" 14 days after the "Issue Date" that is reformatted
It already is 14 days after the inv_date. Are you asking about getting it formatted the same way? Then use DATE_FORMAT in the same way (except inv_date is replaced with the DATE_ADD you have there now).

Re: Query using date_add and date_format

Posted: Tue Nov 06, 2012 7:12 pm
by Alpal
Thanks
That is what I want to do but do not know how to put it all together :banghead:

Re: Query using date_add and date_format

Posted: Tue Nov 06, 2012 8:34 pm
by Alpal
Resolved the problem using php

<?php $newDate = date("M d, Y", strtotime($row_inv_pay['duedate'])); echo $newDate; ?>

Obviously I use dreamweaver - the recordset name is inv_pay

Would have preferred to do it in the query though if anyone can assist would appreciate.