Hi, How to calculate the number of difference between a specific date to the current year last date. Consider I would like to show date difference between 2009-09-01 to current year last date(2010-12-31)
A:
use datediff function:
http://dev.mysql.com/doc/refman/5.1/en/date-and-time-functions.html#function_datediff
Michael Pakhantsov
2010-09-01 11:27:30
A:
mysql have a function for everything.
One you need in this particular case is TO_DAYS()
Col. Shrapnel
2010-09-01 11:28:55
+3
A:
Use to_days
:
select to_days(concat(year(now()),'-12-31')) - to_days(now()) as days_left;
+-----------+
| days_left |
+-----------+
| 121 |
+-----------+
or use datediff like this
select datediff(concat(year(now()),'-12-31'), now()) as days_left;
+-----------+
| days_left |
+-----------+
| 121 |
+-----------+
Paul Dixon
2010-09-01 11:29:55