Its very easy to select records between two different date in MS SQL and MySQL. Same kind of query will work in both the SQL engines.
Here is the query note it down or memorize for the future use, Its very simple though.
Syntax:
SELECT * FROM tablename WHERE columname between ‘date1’ and ‘date2’;
Lets consider the below example table:
Table name: employee
Id | Name | Designation | Dttime |
1 | Agurchand | Software Engineer | 2013-01-07 11:47:10 |
2 | Babu | Software Engineer | 2013-01-02 01:06:00 |
3 | Abhiesheik | Broadcast Engineer | 2013-01-10 18:04:02 |
4 | Juki | Content Writer | 2012-12-27 06:16:32 |
5 | Aparna | Social Executive | 2013-01-27 03:47:00 |
6 | Arun | Sofware Engineer | 2012-12-27 08:12:10 |
SELECT * FROM employee WHERE Dttime between '2012-01-01' and '2012-02-01';
The above query will return the below result:
Id | Name | Designation | DateTime |
1 | Agurchand | Software Engineer | 2013-01-07 11:47:10 |
2 | Babu | Software Engineer | 2013-01-02 01:06:00 |
3 | Abhiesheik | Broadcast Engineer | 2013-01-10 18:04:02 |
5 | Aparna | Social Executive | 2013-01-27 03:47:00 |
I hope this would have helped you! Thanks for coming here!