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)
 Finding Time

Author  Topic 

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2003-10-15 : 06:37:49
I have a date field that defaults to a time value of 00:00:00:0000 I need a select statement that finds all of the data that doesn't equal the default (regardless of the datepart)

I tried

SELECT TIME FROM TABLE WHERE TIME <> <Various Combinations of dates and times>

but none of them seemed to extract what I wanted. Any clues anybody?

thanks

steve

Steve no function beer well without

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-10-15 : 07:27:03
[code]
select
time
from
table
where
time <> dateadd(dd,datediff(dd,0,time),0)
[/code]
 


Jay White
{0}
Go to Top of Page

elwoos
Master Smack Fu Yak Hacker

2052 Posts

Posted - 2003-10-15 : 07:50:22
Thankyou

Steve no function beer well without
Go to Top of Page

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2003-10-15 : 13:26:54
... or

WHERE convert(varchar, time, 114) <> '00:00:00:000'

114

Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2003-10-15 : 13:53:52
I would expect the conversion to be slower. I'm pretty sure I've tested this in the past, but not with 114 ... Don't have time at the minute to run perf testing on it ...

Jay White
{0}
Go to Top of Page

Stoad
Freaky Yak Linguist

1983 Posts

Posted - 2003-10-15 : 14:04:49
Hm... interesting... really needs testing.
Go to Top of Page
   

- Advertisement -