Select records DateTime field that match todays date

VKugel
VKugel used Ask the Experts™
on
I have a VB.net 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.
Regards,
Comment
Watch Question

Do more with

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

Commented:

use this

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

Author

Commented:

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

Commented:
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!

Author

Commented:
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.
Commented:
This is the solution I found:
"Select * from Leads where datediff(day, CreatedDate, getdate())=0"
Top Expert 2012

Commented:
>>"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