Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 selecting dates?

Author  Topic 

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2010-11-15 : 13:40:31
The date is a datetime that looks like this "2010-11-10 10:28:23.227"

So I need to searck on these dates by passing the Stored proc a date like 11/10/2010. How do I do this? Nov 10th

Dave
Helixpoint Web Development
http://www.helixpoint.com

TimSman
Posting Yak Master

127 Posts

Posted - 2010-11-15 : 13:54:37
Do you care about the time part at all?
Go to Top of Page

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2010-11-15 : 14:04:52
Nope

Dave
Helixpoint Web Development
http://www.helixpoint.com
Go to Top of Page

helixpoint
Constraint Violating Yak Guru

291 Posts

Posted - 2010-11-15 : 14:28:17
Actually I just need yesterdays date??

Dave
Helixpoint Web Development
http://www.helixpoint.com
Go to Top of Page

TimSman
Posting Yak Master

127 Posts

Posted - 2010-11-15 : 14:28:30
SELECT
columns
FROM
table
WHERE
(CONVERT(date, '11/10/2010') = CONVERT(date, columnname))
Go to Top of Page

Lamprey
Master Smack Fu Yak Hacker

4614 Posts

Posted - 2010-11-15 : 17:35:34
[code]SELECT *
FROM MyTable
WHERE MyDateColumn >= '20101110' AND MyDateColumn < '20101111'

-- Or to use a parameter
SELECT *
FROM MyTable
WHERE MyDateColumn >= CAST(@MyDateParam AS DATE) AND MyDateColumn < DATEADD(DAY, 1, CAST(@MyDateParam AS DATE))[/code]
Go to Top of Page
   

- Advertisement -