Question : SQL view

I have a start date/time stamp and an end date/time stamp in a table.  I want to create a view that subtracts the two date/time stamps to arrive at the number of days (in integer format) it takes to complete a task.  I than want to compare the number of days it takes to complete a task and assign a character to that value.  For example, if I takes 0 days to finish a task the character value assigned would be Same Day.  If it takes 1 day to finish a task the character value will be 1 day.  Once the values get to 8 and above the character value will be 8-14 days, 15-25 days.  

Answer : SQL view

try like this
1:
2:
3:
4:
5:
6:
7:
8:
select case when datediff(d,StartDt,EndDt) = 0 then '0 days'
            when datediff(d,StartDt,EndDt) = 1 then '0 day'
            when datediff(d,StartDt,EndDt) = 2 then '2 days' 
            ...
            ...
            when datediff(d,StartDt,EndDt) between 8 and 14 then '8-14 days'
            when datediff(d,StartDt,EndDt) between 15 and 25 then '15-25 days' end as Diff
  from Yourtable
Random Solutions  
 
programming4us programming4us