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

change column name and make a unique column so we get no dupes.

0 Answers  


What is diff b/w MYISAM and INNODB storage engine. and also define the benifits and drawbacks of both storage engine

1 Answers  


What is a mysql model?

0 Answers  


What is sql vs mysql?

0 Answers  


How to create a trigger in mysql?

0 Answers  






Is mysql good for large database?

0 Answers  


is it possible to assign two primary key in a table

8 Answers   IBM,


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

0 Answers  


Is mysql port 3306 tcp or udp?

0 Answers  


How do you restart mysql?

0 Answers  


How do you control the max size of a HEAP table?

1 Answers  


What does mysqli stand for?

0 Answers  


Categories