I need to convert a calculation from VBS to Sql server to the whole number and the nearest tenth. This is the calculation on VB:
a=2/28/2016
b=6/15/2016
d=1
Days360(a, b) = 107
-INT(-(10^d)*DAYS360(a,b)/30)/(10^d) =
-INT(-(10^1)*107/30)/(10^1) =
-INT(-10*107/30)/10 =
-INT(-1070/30)/10 =
-INT(-35.666667)/10 =
-(-36)/10 =
36/10 = 3.6 --- result for nearest tenth
a=2/28/2016
b=6/15/2016
d=0
Days360(a, b) = 107
-INT(-(10^d)*DAYS360(a,b)/30)/(10^d) =
-INT(-(10^0)*107/30)/(10^0) =
-INT(-1*107/30)/1 =
-INT(-107/30)/1 =
-INT(-3.5666667)/1 =
-(-4)/1 =
4/1 =4 ---result for the whole number
How do I convert these two to sql? I use these two queries but I don't get the results I expected:
SELECT ROUND(DATEDIFF(day,'2016-02-28','2016-06-15')*10/30/10,0) AS DiffDate
SELECT ROUND(DATEDIFF(day,'2016-02-28','2016-06-15')*10/30/10,1) AS DiffDate