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
 General SQL Server Forums
 New to SQL Server Programming
 Convert column from datetime to true/false

Author  Topic 

serialhobbyist
Starting Member

2 Posts

Posted - 2011-06-14 : 10:52:13
I have a table of datetime columns. I want to create a view that replaces each column with a true/false indication.

The value will be true, for each column, when the datetime in that column is less than the datetime when the view is run.

I tried something like:

SELECT (DeletionDate < GetDate()) AS DeleteMeNow but I got a syntax error on the '<'. Am I going about this the wrong way?

robvolk
Most Valuable Yak

15732 Posts

Posted - 2011-06-14 : 11:08:49
SELECT CASE WHEN DeletionDate < GetDate() THEN 'True' ELSE 'False' END AS DeleteMeNow
Go to Top of Page

serialhobbyist
Starting Member

2 Posts

Posted - 2011-06-14 : 11:29:10
Brilliant! Thanks very much.
Go to Top of Page
   

- Advertisement -