Calcolo della differenza tra due date in giorni
Jump to navigation
Jump to search
Preso da Date difference in MySQL
Calcolare la differenza in giorni tra due date in MySQL
Heres a handy reference that uses MySQL to find the number of days between two dates.
From the MySQL standpoint, this is obviously a popular thing to do, because as of version 4.1.1, there are explicit functions that do just that. But, as of this date, version 4.1.1 is not the release build, so I will mention another way to do it.
Prior to MySQL 4.1.1:
SELECT TO_DAYS('2004-11-08') - TO_DAYS('2004-07-26');
> 105
As of MySQL 4.1.1:
SELECT DATEDIFF('2004-11-08','2004-07-26');
> 105
The dates I used are just examples. Obviously, you can insert any dates in there, as long as the most recent date is listed first.