I'm looking to work out the difference between 2 dates that I have declared as variables,
DECLARE @start_date DATETIME
SET @start_date= '20000728'
DECLARE @end_date DATETIME
SET @end_date= '20161028'
DATEDIFF(DAY, @start_date, @end_date) AS 'DAYS_AVAIL_RANGE'
select (case when @start_date > date_created then datediff(DAY, @start_date, @end_date) else datediff(DAY, date_created, @end_date) end) as days_avail_range