Quantcast
Channel: SQL Server Integration Services forum
Viewing all articles
Browse latest Browse all 24688

CASE

$
0
0

Hi,

From the query below, if shipdate is null then I use the planneddate, else I use the shipdate to compare between from and to.  Not sure what I have wrong here, but it did not work for me.  Can you please help.-thanks

declare @ID int
declare @bp nvarchar(20)
declare @From date
declare @To date

set @ID =99
set @bp = '30'
set @From ='10/21/2019'
set @To ='10/21/2019'

select  ID,orders,bp, plandedate,shipdate
from  saleorders
where [ID]=@ID
and bp =@bp
and 
case when shipdate is null then  plandedate between CONVERT(date, @From,101) and CONVERT(date,@To,101)
  else   shipdate between CONVERT(date, @From,101) and CONVERT(date,@To,101)

end


Viewing all articles
Browse latest Browse all 24688

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>