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
What is the difference between mysql and oracle?
What is difference between schema and table?
What is mysql database extension?
How do I make an action query?
How to see the create table statement of an existing table?
What ascii 31?
What does tinyint mean?
Why are function needed?
What is the data type for image?
How to change a password for an existing user via mysqladmin?
What is InnoDB?
What is the use of innodb in mysql?
Is mysql running ubuntu?
Write a query to select all teams that won either 1, 3, 5 or 7 games.
What are the similarities between a function and a procedure?