Click here to Skip to main content
Click here to Skip to main content
Alternative Tip

Accurate DATETIME Range Searching in SQL Server

, 1 Jul 2010
Rate this:
Please Sign up or sign in to vote.
You can also get the correct result by passing time along with the date.ExampleIf you have to search records between 1st Apr 2010 and 5th Apr 2010, then:Select * from TableNameWhere DateField Between '04/01/2010 00:00:00' And '04/01/2010 23:59:59'
You can also get the correct result by passing time along with the date.
 
Example
 
If you have to search records between 1st Apr 2010 and 5th Apr 2010, then:
 
Select * from TableName
Where DateField Between '04/01/2010 00:00:00' And '04/01/2010 23:59:59'

License

This article, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

About the Author

Chetan Patel
Software Developer (Senior)
India India
Development tool doesn't matter.
Chetan Patel
Gujarat-India.

Comments and Discussions

 
GeneralMy vote of 1 PinmemberMember 852840922-Oct-12 8:53 

General General    News News    Suggestion Suggestion    Question Question    Bug Bug    Answer Answer    Joke Joke    Rant Rant    Admin Admin   

Use Ctrl+Left/Right to switch messages, Ctrl+Up/Down to switch threads, Ctrl+Shift+Left/Right to switch pages.

| Advertise | Privacy | Mobile
Web01 | 2.8.140721.1 | Last Updated 1 Jul 2010
Article Copyright 2010 by Chetan Patel
Everything else Copyright © CodeProject, 1999-2014
Terms of Service
Layout: fixed | fluid