DelphiFAQ Home Search:

Compare 2 dates in mysql

 

comments3 comments. Current rating: 4 stars (1 votes). Leave comments and/ or rate it.

Question:

I need to compare 2 dates in mysql but I only have version 3.23 of mysql installed and cannot upgrade.

Answer:

With mysql 4.1.1 the function datediff(date1,date2) and others were introduced.

If you are using 4.0 or older, you need to use to_days(date1) and subtract in this form:

select TO_DAYS(NOW()) - TO_DAYS(last_modification)
from mytable;

Comments:

2006-09-01, 03:03:22
anonymous from India  
hey its not date_diff, its datediff(date1, date2) in the latest versions of mysql...
2006-09-01, 10:28:21
Peter (Author/ Admin) from United States  
thanks, I corrected it.
2007-03-30, 00:03:58
anonymous from India  
rating
Fine and good

Jaypal Mandloi

9826058584

 

 

Email address (not necessary):

Rate as
Hide my email when showing my comment.
Please notify me once a day about new comments on this topic.
Please provide a valid email address if you select this option.
 
It seems that you are
from Los Angeles, US .

Info/ Feedback on this

Show city and country
Show country only
Hide my location
You can mark text as 'quoted' by putting [quote] .. [/quote] around it.
Please type in the code:
photo Add a picture:

Please do not post inappropriate pictures. Inappropriate pictures include pictures of minors and nudity. The owner of this web site reserves the right to delete such material.