Want to protect your cyber security and still get fast solutions? Ask a secure question today.Go Premium

x
?
Solved

Date Field Null Comparison problem in Stored Procedure using CASE statement

Posted on 2006-05-15
1
Medium Priority
?
228 Views
Last Modified: 2012-06-27
I have the following statement in my stored procedure as a part of the select statement

CASE WHEN dbo.properties.RefAgreeRecd = NULL
THEN
DATEDIFF(d , dbo.properties.ReoAssignDate , GETDATE())
ELSE
- 1 * DATEDIFF(d , dbo.properties.reoassigndate , dbo.properties.RefAgreeRecd)
END

The statment works fine for everything except null values.  It returns null instead of returning the difference between today and REOAssignDate which has a date in it.

Thanks
0
Comment
Question by:softdimensions
1 Comment
 
LVL 17

Accepted Solution

by:
HuyBD earned 2000 total points
ID: 16687218
Could you try with "is" insteed of "="

CASE WHEN dbo.properties.RefAgreeRecd IS NULL
THEN
DATEDIFF(d , dbo.properties.ReoAssignDate , GETDATE())
ELSE
- 1 * DATEDIFF(d , dbo.properties.reoassigndate , dbo.properties.RefAgreeRecd)
END
0

Featured Post

Keep up with what's happening at Experts Exchange!

Sign up to receive Decoded, a new monthly digest with product updates, feature release info, continuing education opportunities, and more.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

Ever wondered why sometimes your SQL Server is slow or unresponsive with connections spiking up but by the time you go in, all is well? The following article will show you how to install and configure a SQL job that will send you email alerts includ…
MSSQL DB-maintenance also needs implementation of multiple activities. However, unprecedented errors can hamper the database management. In that case, deploying Stellar SQL Database Toolkit ensures fast and accurate database and backup repair as wel…
This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
Viewers will learn how the fundamental information of how to create a table.
Suggested Courses

571 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question