Mysql Date Comparison is used to return the date from a table on the basis of comparison between any two values of dates.
Understand with Example
The Tutorial illustrate an example from 'Mysql Date Comparison'. To understand this example we create a table 'Employee1' in the database.
Step1:-Create table name EMPLOYEE1 in the database:-
|CREATE TABLE EMPLOYEE1 (
ID int(2) NOT NULL auto_increment,
DAT date NOT NULL default '0000-00-00',
PRIMARY KEY (ID)
Step2:-Insert the values in the table by giving the query given below:-
|INSERT into EMPLOYEE1 VALUES
Step3:-Write the query given below for comparing the given two dates:-
The Query below return you the set of records from 'Employee1' whose value of date is greater than equal to '2008-12-01' and less than equal to '2008-12-03'.
|SELECT * FROM EMPLOYEE1
WHERE DAT >='2008-12-01' AND DAT <='2008-12-03';
If you are facing any programming issue, such as compilation errors or not able to find the code you are looking for.
Ask your questions, our development team will try to give answers to your questions.