How can we know the number of days between two given dates
using MySQL?

Answer Posted / sergii

DATEDIFF(expr1,expr2)

DATEDIFF() returns expr1 – expr2 expressed as a value in
days from one date to the other. expr1 and expr2 are date
or date-and-time expressions. Only the date parts of the
values are used in the calculation.

mysql> SELECT DATEDIFF('1997-12-31 23:59:59','1997-12-30');
-> 1
mysql> SELECT DATEDIFF('1997-11-30 23:59:59','1997-12-31');
-> -31

Is This Answer Correct ?    9 Yes 1 No



Post New Answer       View All Answers


Please Help Members By Posting Answers For Below Questions

How do I find mysql database?

480


What is myisamchk?

508


What are the steps required to view your mysql database?

600


How do I find users in mysql?

524


Is mysql same as mariadb?

473






Why we use mysql workbench?

469


How do I download mysql on my laptop?

479


How do I rename a table in mysql?

491


How to use like conditions?

540


explain GROUPBY & HAVING clause with examples.

1827


Is there a way to see the files which are stored?

490


What is flush privileges in mysql?

518


what is the difference between the nvl function, ifnull function, and the isnull function? : Mysql dba

523


What is mysql default port number?

529


What is tee command in mysql?

483