July 7, 2008 at 5:45 am
Hi All,
I want to split integer part from decimal value
e.g. i have a no is 12456324.254 and i want to the output is 12456324
Note: We can't use convert function
July 8, 2008 at 5:16 am
Function floor() does not work? :unsure:
July 8, 2008 at 5:31 am
Thanks,
It is working
July 8, 2008 at 2:21 pm
or, use
ROUND(YourValue, 1)
(revised) I'm sorry... I meant ROUND(YourValue, 0, 1)
I apologize for my lack of proof-reading.
The non-zero 2nd parameter truncates the value, without changing the datatype.
July 8, 2008 at 2:40 pm
indraprakash (7/7/2008)
Note: We can't use convert function
The ROUND function with the truncate option is definately the way to go... but why is it that you can't use the CONVERT function?
--Jeff Moden
Change is inevitable... Change for the better is not.
July 8, 2008 at 10:18 pm
Hi,
round function not gives proper output
floor is right.
July 8, 2008 at 10:53 pm
indraprakash (7/8/2008)
Hi,round function not gives proper output
floor is right.
Ummmm.... why do you think that? Using the optional 3rd parameter of ROUND makes it behave like FLOOR but with more control, if you need it.
--Jeff Moden
Change is inevitable... Change for the better is not.
July 9, 2008 at 7:54 am
I'm sorry... I meant ROUND(YourValue, 0, 1)
I apologize for my lack of proof-reading.
July 9, 2008 at 8:09 am
No problem and thanks for the feedback, Phil... I've made similar mistakes... just wanted to be sure...:)
--Jeff Moden
Change is inevitable... Change for the better is not.
August 8, 2011 at 7:54 pm
What if i want the other value not the floor value ...........
i mean if its 1234.4321
i want 4321 (values after the decimal place...)?
Cheers,
Chandra
August 8, 2011 at 9:36 pm
If you can't use convert(), you can always use cast(). BTW, I can't remember how floor() behaves for negative numbers, but I know there's a reason I end up using round() instead.
August 8, 2011 at 10:03 pm
vchandm23 (8/8/2011)
but is there a function that does this in SQL Server
Not in any version of SQL Server that I know of. You're pretty much stuck with doing the math like you did.
--Jeff Moden
Change is inevitable... Change for the better is not.
August 9, 2011 at 11:31 am
vchandm23:
What about using modulus (%)? Like some flavor of the following:
select replace(1234.4321 % 1 ,'0.','')
Viewing 15 posts - 1 through 14 (of 14 total)
You must be logged in to reply to this topic. Login to reply