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.
| Author |
Topic |
|
Blastrix
Posting Yak Master
208 Posts |
Posted - 2002-05-31 : 13:22:44
|
Is it possible to do something along the lines of: SELECT Result = (DateDiff("n", @Date, Somewhere.DateColumn) > 1)FROM SomewhereI always get an error at > 1, is there some way to do this in the query? Maybe I'm just getting it wrong? Thanks,Steve |
|
|
setbasedisthetruepath
Used SQL Salesman
992 Posts |
Posted - 2002-05-31 : 13:29:18
|
It's not terribly clear what you're looking for.Do you mean:select DateDiff("n", @Date, Somewhere.DateColumn) as resultfrom {sometable}where DateDiff("n", @Date, Somewhere.DateColumn) > 1are you expecting a singleton result, and looking to put the datediff() quantity into a variable?set @result = ( select (DateDiff("n", @Date, Somewhere.DateColumn) from {sometable} where DateDiff("n", @Date, Somewhere.DateColumn) > 1)quote: Is it possible to do something along the lines of: SELECT Result = (DateDiff("n", @Date, Somewhere.DateColumn) > 1)FROM SomewhereI always get an error at > 1, is there some way to do this in the query? Maybe I'm just getting it wrong? Thanks,Steve
setBasedIsTheTruepath<O> |
 |
|
|
Blastrix
Posting Yak Master
208 Posts |
Posted - 2002-05-31 : 13:32:19
|
| No, not quite. That was just a small sample of a larger query. What I need result to be is a boolean flag indicating whether or not the specified date is greater than the creation date of the record. |
 |
|
|
Page47
Master Smack Fu Yak Hacker
2878 Posts |
Posted - 2002-05-31 : 13:45:26
|
you need a case functionselect case when @Date > datecolumn then 1 else 0 end as Resultfrom somewhere <O> |
 |
|
|
|
|
|
|
|