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 2005 Forums
 Transact-SQL (2005)
 return true/false on statement

Author  Topic 

Xorbit
Starting Member

3 Posts

Posted - 2009-01-03 : 15:10:04
Hi,

I want a select statement to return true/false on whether a date is before or after another giveen date.

I have tried with:
SELECT
(tablename.createdate > '2008-12-10') as beforeAfter
FROM Tablename
...

But I get the error:
Incorrect syntax near '>'.

Is there a workaround to this that anybody know about?

SwePeso
Patron Saint of Lost Yaks

30421 Posts

Posted - 2009-01-03 : 15:11:23
SELECT CASE WHEN CreateDate > '2008-12-10' THEN 'true' ELSE 'false' END AS BeforeAfter
FROM TableName



E 12°55'05.63"
N 56°04'39.26"
Go to Top of Page

Xorbit
Starting Member

3 Posts

Posted - 2009-01-03 : 15:33:32
Thanks a lot, works like a charm :-)
Go to Top of Page
   

- Advertisement -