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

Consider you have the following three tables which have to be linked together.

693


Is mysql an oracle product?

655


What is different between sql and mysql?

691


Why phpmyadmin is used for mysql?

678


Can we join 3 tables in mysql?

684


What is 'mysqldump'?

725


I want to find out all databases starting with ‘test’, I have access to?

858


How do I delete a table in mysql workbench?

723


How to see table's field formats or description of table .

642


What is a procedure example?

667


What is query log in mysql?

657


What is bigint in mysql?

688


What is difference between mysql mysqli and pdo?

636


What data type is money?

626


Write a command with which mysql table can be repaired

722