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 2000 Forums
 Transact-SQL (2000)
 help debug

Author  Topic 

esthera
Master Smack Fu Yak Hacker

1410 Posts

Posted - 2005-03-16 : 13:51:38
select * from users where ak=1 and mydate=CONVERT(datetime, '3/16/2005', 101)

mydate is a date time field

there are records with the date of 3/16 but when I run the sql above it returns no records

why?

PW
Yak Posting Veteran

95 Posts

Posted - 2005-03-16 : 13:55:20
>>there are records with the date of 3/16

But what are the time components of the data columns in those records.
If querying on a datetime, you need to go down to the millisecond level to match.

You could also use a range without time component:

select * from users
where ak=1
and mydate >= '3/16/2005'
and mydate < '3/17/2005'

Go to Top of Page
   

- Advertisement -