Apr 7, 2006 #1 myvision69 Programmer Joined Feb 3, 2006 Messages 18 Location US i have a decimal number stored but i want to display the whole number only with three digits and no decimal places. how can i do that in SQL? Thanks
i have a decimal number stored but i want to display the whole number only with three digits and no decimal places. how can i do that in SQL? Thanks
Apr 7, 2006 #2 gmmastros Programmer Joined Feb 15, 2005 Messages 14,912 Location US SQL has a round function, or you could convert it to another decimal(but with a different precision). Declare @Temp Decimal(10,5) Set @Temp = 123.75678 Select @Temp, Round(@Temp, 0), Convert(decimal(10,0), @Temp) -George Strong and bitter words indicate a weak cause. - Fortune cookie wisdom Upvote 0 Downvote
SQL has a round function, or you could convert it to another decimal(but with a different precision). Declare @Temp Decimal(10,5) Set @Temp = 123.75678 Select @Temp, Round(@Temp, 0), Convert(decimal(10,0), @Temp) -George Strong and bitter words indicate a weak cause. - Fortune cookie wisdom
Apr 7, 2006 Thread starter #3 myvision69 Programmer Joined Feb 3, 2006 Messages 18 Location US e.g. 78.00 needs to be displayed as 078 1.00 needs to be dispayed as 001 150.00 needs to be displayed as 150 How can I accomplish that? Upvote 0 Downvote
e.g. 78.00 needs to be displayed as 078 1.00 needs to be dispayed as 001 150.00 needs to be displayed as 150 How can I accomplish that?
Apr 7, 2006 1 #4 vongrunt Programmer Joined Mar 8, 2004 Messages 4,863 Location HR If you have to... See CONVERT() and ROUND() functions in Books Online. ------ [small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small] Upvote 0 Downvote
If you have to... See CONVERT() and ROUND() functions in Books Online. ------ [small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]
Apr 7, 2006 #5 vongrunt Programmer Joined Mar 8, 2004 Messages 4,863 Location HR Quick & dirty trick: Code: select right(convert(decimal(4, 0), 1000 + yourvaluehere), 3) ------ [small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small] Upvote 0 Downvote
Quick & dirty trick: Code: select right(convert(decimal(4, 0), 1000 + yourvaluehere), 3) ------ [small]select stuff(stuff(replicate('<P> <B> ', 14), 109, 0, '<.'), 112, 0, '/')[/small]