I'm tring to calculate the aging value of an invoice. Here is the SQL statement:
SELECT invoice_number, company_name, curdate( ) , invoice_date,
curdate( ) - invoice_date AS aging
FROM invoices
Here is one of the lines that is returned:
56554 Company A 2005-08-08 2005-07-28 80
The aging value is 80 but should be 11.
curdate() returns wrong values
Moderator: General Moderators
- bluesman333
- Forum Commoner
- Posts: 52
- Joined: Wed Dec 31, 2003 9:47 am
- feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
if you do the math.. it acutally is 80. Not date math, as in convert the two dates to numeric (perform them as math operations.)
if you have MySQL 4.1.1+ you can use DATE_DIFF().. otherwise, you can convert them to unix timstamps: UNIX_TIMESTAMP() then do the actual math.
if you have MySQL 4.1.1+ you can use DATE_DIFF().. otherwise, you can convert them to unix timstamps: UNIX_TIMESTAMP() then do the actual math.