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
 SQL Server Development (2000)
 Return an Evaluation?

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
Somewhere


I 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 result
from {sometable}
where DateDiff("n", @Date, Somewhere.DateColumn) > 1

are 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
Somewhere


I 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>
Go to Top of Page

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.

Go to Top of Page

Page47
Master Smack Fu Yak Hacker

2878 Posts

Posted - 2002-05-31 : 13:45:26
you need a case function


select
case
when @Date > datecolumn then 1
else 0
end as Result
from
somewhere

 


<O>
Go to Top of Page
   

- Advertisement -