Calcolo della differenza tra due date in giorni

From RVM Wiki
Revision as of 18:25, 16 August 2005 by Gabriele.vivinetto (talk | contribs)
(diff) ← Older revision | Latest revision (diff) | Newer revision → (diff)
Jump to navigation Jump to search

Preso da Date difference in MySQL


Calcolare la differenza in giorni tra due date in MySQL

Here’s 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.


MySQL Reference Manual :: 3.3.4.5 Date Calculations