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)
 Conditional Stmt resulting in query,not a column

Author  Topic 

zefiros
Starting Member

16 Posts

Posted - 2008-04-01 : 05:18:17
Hi i want to be able to search within a specific period, inside the table I have stored StartDate and EndDate. What I want to do is not to execute a part of the code when EndDate is null. I've tried something like this:

AND (CWCREWSERV.DATEE BETWEEN CONVERT(DATETIME, '15/03/2008', 103) AND CONVERT(DATETIME, '31/03/2008', 103))
AND CASE WHEN CWCREWSERV.DATED IS NOT NULL THEN
CWCREWSERV.DATED BETWEEN CONVERT(DATETIME, '15/03/2008', 103) AND CONVERT(DATETIME, '31/03/2008', 103) END

I know that SQL expects a column as a result and define END = 0 or 1, any ideas? Thanks

zefiros
Starting Member

16 Posts

Posted - 2008-04-01 : 05:35:18
Sorry my sily mistake on my tests carried me away.. My original code actually works

AND ((CWCREWSERV.DATED BETWEEN CONVERT(DATETIME, '10/03/2008', 103) AND CONVERT(DATETIME, '31/03/2008', 103))
OR CWCREWSERV.DATED IS NULL)

I would like to know though how the thing I've asked works, Thanks!
Go to Top of Page
   

- Advertisement -