Reputation: 600
I got problem when converting float to varchar and it's alway round up. for the example
if I convert : 0.65 it became 1, but I only want 0 1.55 it became 2, but I only want 1
here's my code :
Declare @Dt1 dateTime Set @Dt1 = '2014-03-05 10:15:53.110'
Declare @Dt2 dateTime Set @Dt2 = getdate()
Select str((Cast((@Dt2 - @Dt1) as Float) * 24.0)) as hours1 ,
str(Cast((@Dt2 - @Dt1) as Float) * 24.0*60.0)%60 as minutes1
is it possible to avoid rounding up when converting ?
Upvotes: 0
Views: 653
Reputation: 5439
Have you tried ROUND
method? However the following SQL may fit your requirement:
Select str((Cast((@Dt2 - @Dt1) as Float) * 24.0)) as hours1 ,
str(ROUND(Cast((@Dt2 - @Dt1) as Float) * 24.0*60.0, 0, 1))%60 as minutes1
Upvotes: 2