MySQL Forums
Forum List  »  PHP

Re: difference of dates
Posted by: Jay Pipes
Date: June 27, 2005 08:55AM

Easy. Just use TO_DAYS():

mysql> CREATE TABLE test1 (some_date DATE NOT NULL);
Query OK, 0 rows affected (0.50 sec)

mysql> INSERT INTO test1 VALUES ('2005-06-01');
Query OK, 1 row affected (0.08 sec)

mysql> SELECT DATEDIFF(some_date, NOW()) as diff FROM test1;
+------+
| diff |
+------+
| -26 |
+------+
1 row in set (0.14 sec)

mysql> SELECT TO_DAYS(some_date) - TO_DAYS(NOW()) as diff FROM test1;
+------+
| diff |
+------+
| -26 |
+------+
1 row in set (0.03 sec)

Jay Pipes
Community Relations Manager, North America, MySQL Inc.

Got Cluster? http://www.mysql.com/cluster
Personal: http://jpipes.com

Options: ReplyQuote


Subject
Written By
Posted
June 26, 2005 01:21PM
June 27, 2005 08:29AM
Re: difference of dates
June 27, 2005 08:55AM
June 27, 2005 11:58AM


Sorry, you can't reply to this topic. It has been closed.

Content reproduced on this site is the property of the respective copyright holders. It is not reviewed in advance by Oracle and does not necessarily represent the opinion of Oracle or any other party.