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

Answers were Sorted based on User's Feedback



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

Answer / 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

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

Answer / shwetha

There is a operator {not} BETWEEN ,we can use this in where
clause to get in between dates.
ex:
select count(column name)
from table1
where dates BETWEEN '01-jul-04' and '01-jul-05';

Is This Answer Correct ?    4 Yes 4 No

Post New Answer

More MySQL Interview Questions

Why phpmyadmin is used for mysql?

0 Answers  


What is the difference between unix timestamps and mysql timestamps?

0 Answers  


What is database clustering in mysql?

0 Answers  


What is mysql primary key?

0 Answers  


How to create trigger in mysql workbench?

0 Answers  






how fastest access of data can be done from database ?

3 Answers  


Can anyone help me to create a good mysql database schema with an example. Thanks, Sekar.jr

1 Answers  


How do you restart mysql?

0 Answers  


when i declare date data type in sql ,i inserted the date 22-10-2012,but my result is in different date 1894-07-11 any one pls help me what's wrong in my query Create table orders(od_id int,od_name varchar(10),od_date date) insert into orders values(1,'sai',22-10-2012) and any one pls suggest what i can learn for 3 years real time experenice in sql because i am looking for database field

1 Answers  


How can we find the number of rows in a table using MySQL?

3 Answers  


How to rename an existing table in mysql?

0 Answers  


What is difference between mongodb and mysql?

0 Answers  


Categories