DelphiFAQ Home Search:
General :: Databases :: mysql
General information about mysql - how to get around the differences between version 3.33 an 4, how to do stuff that you think you need a nested query for etc.

Articles:

This list is sorted by recent document popularity (not total page views).
New documents will first appear at the bottom.

Featured Article

Compare 2 dates in mysql

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;

Generated 16:00:42 on Jul 16, 2019