Search records based on particular Date in sql

Madhu.B.Rokkam
Posted by Madhu.B.Rokkam under Sql Server category on | Points: 40 | Views : 1348
Search records based on particular Date in sql

Select  column1, column2, createdDate from tSearchTable 
where DATEPART(month, dtmCreatedDate) = 10
and DATEPART(day, dtmCreatedDate) = 26
and DATEPART(year, dtmCreatedDate) = 2012

Comments or Responses

Posted by: Jasminej on: 10/26/2012 Level:Starter | Status: [Member] | Points: 10
What about the performance using this method ?

thank you
Posted by: T.Saravanan on: 10/28/2012 Level:Silver | Status: [Member] [MVP] | Points: 10
@Madhu, Is there any problem in direct condition? like
"CONVERT(DATETIME, dtmCreatedDate, 101) = '10/26/2012'"

Posted by: Mohaiselva on: 11/2/2012 Level:Starter | Status: [Member] | Points: 10
CONVERT(DATE,dtmCreatedDate) = '2012-11-02'
I think it is the best method to get the record in particular date.

Login to post response