First, let me thank you for helping!
Now I'm converting a query to a view in SQL so I need to replace all my variables with actual values. However I am running into trouble when doing this.
When I have
DECLARE @TweleveAM datetime
set @TweleveAM = '1900-01-01 00:00:00'
DECLARE @TweleveThirtyAM datetime
set @TweleveThirtyAM = '1900-01-01 00:30:00'
WHEN (cast(segstart as float) - floor(cast(segstart as float))) >=
(cast(@TweleveAM as float) - floor(cast(@TweleveAM as float)))
and (cast(segstart as float) - floor(cast(segstart as float))) <
(cast(@TweleveThirtyAM as float) - floor(cast(@TweleveThirtyAM as float)))
THEN CAST('0' as int)
And instead I use
WHEN (cast(segstart as float) - floor(cast(segstart as float))) >=
(cast(cast('1900-01-01 00:00:00' as datetime)as float) -
floor(cast(cast('1900-01-01 00:00:00' as datetime) as float)))
and (cast(segstart as float) - floor(cast(segstart as float))) <
(cast(cast('1900-01-01 00:00:30' as datetime) as float) -
floor(cast(cast('1900-01-01 00:00:30' as datetime) as float)))
THEN CAST('0' as int)
ELSE Null End as Interval
My query produces Null, when in fact the data is never NULL.
What am I doing wrong here?