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)
 How check Date null and Date Diff

Author  Topic 

getur.srikanth@gmail.com
Yak Posting Veteran

77 Posts

Posted - 2008-01-18 : 12:00:48

my parameters @FromDate and @ToDate.

I have to check Null dates and taffDate Between @FromDate and @Todate in Select statement.

WHERE
(@FromDate is null or @ToDate is Null or taffDate BETWEEN @FromDate and @ToDate).

Is this way right?

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2008-01-18 : 12:05:30
nope. use like this

WHERE (@FromDate is null OR taffDate>=@FromDate)
AND (@ToDate is Null OR taffDate <=@ToDate)
Go to Top of Page

getur.srikanth@gmail.com
Yak Posting Veteran

77 Posts

Posted - 2008-01-18 : 12:16:29
thanks
Go to Top of Page
   

- Advertisement -