I have created the below function, and it seems to at random to change the @FCST and @QTY values to random selections. Here is an example of the program in debug returning a bad value for @FCST. As @FCST was at 9.53, I expect it to return 9.53.

CREATE FUNCTION dbo.LTBADJ
(@MAT VARCHAR(30),@LCUT DATE, @QS DATE,@STAT FLOAT, @MCA FLOAT)
RETURNS FLOAT
AS BEGIN
DECLARE @HD DATE
DECLARE @ED DATE
DECLARE @FCST FLOAT
DECLARE @QTY FLOAT
DECLARE @YRS FLOAT
SET @ED =
(SELECT TOP 1 [EO_END_DATE] FROM [dbo].[EO_LTB]
WHERE [W_PART_NUMBER] = @MAT
AND [APPROVED_DATE] <= @LCUT
ORDER BY [EO_END_DATE] DESC)
SET @HD =DATEADD(YEAR,2,@QS)
SET @FCST = (CASE WHEN @MCA <= @STAT THEN @MCA ELSE @STAT END)
SET @FCST = (CASE WHEN @FCST <.5 THEN .5 ELSE @FCST END)
SET @YRS = (DATEDIFF(DAY,@HD,@ED) + 730)/365
SET @QTY = @FCST * @YRS
SET @QTY = (CASE WHEN @ED<=@HD THEN 0 ELSE @QTY END)
RETURN @QTY
END ;
EDIT: Example of @QTY incorrectly calculated

9.53.. that's9.53 x 10^-2=9.53 x 0.01.. which is 0.09535 x 10^-1=5 x 0.1=0.5.. which is what you specified it to be when it's less that 0.521.345+.. what should it be?