Select records DateTime field that match todays date

VKugel used Ask the Experts™
I have a application that uses SQL server 2005. When I created new records in my application I save todays date in a date time field using Now(). When I try and slected records that were created today"m/d/yyyy" I can not get any records.
I am using SQLClient for my database connection.

This is my selection statment:

 "Select * From Leads Where CONVERT(VARCHAR(20),CreatedDate, 101) = '" & DateTime.Parse(Now()).ToString("m/d/yyyy") & "'"

Any help would be appreciated.
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®


use this

 s = "Select * From Leads Where CreatedDate = '" & Now() & "'";



That does not work. That was my first try. I tried it again with no luck.

what is the error message you get?
Success in ‘20 With a Profitable Pricing Strategy

Do you wonder if your IT business is truly profitable or if you should raise your prices? Learn how to calculate your overhead burden using our free interactive tool and use it to determine the right price for your IT services. Start calculating Now!


I don't get an error message. I don't get any records.
My current Created date records are dated 1/31/2010 9:00:58 AM
If I use Now(), it will not match bacause the times do not match.
This is the solution I found:
"Select * from Leads where datediff(day, CreatedDate, getdate())=0"
Top Expert 2012

>>"Select * from Leads where datediff(day, CreatedDate, getdate())=0"<<
Unless you only have a few thousand rows, than that is a very bad idea as it is not scalable. MS SQL Server will not be able to take advantage of any index on the table.

Let us know if you want to do it right.

Do more with

Expert Office
Submit tech questions to Ask the Experts™ at any time to receive solutions, advice, and new ideas from leading industry professionals.

Start 7-Day Free Trial