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

What is pragma exception?

537


What is a join? Explain the different types of mysql joins.

693


What is text?

558


Is mysql free for enterprise?

495


How do I find mysql version in mysql workbench?

488






What are the limitations of mysql?

504


how to get only updated, deleted , inserted records after certain interval time in mysql with out using triggers...

1806


What is a text delimiter?

509


List some mysql advantages and disadvantages?

531


What are the different tables present in MySQL?

562


How to give user privilages for a db. Login as root. Switch to the mysql db. Grant privs. Update privs.

479


How do I change global variables in mysql?

473


In how many ways we can retrieve data in the result set of mysql using php?

615


Why do we need mysql?

523


What is pdo mysql?

505