Click here to monitor SSC
SQLServerCentral is supported by Red Gate Software Ltd.
 
Log in  ::  Register  ::  Not logged in
 
 
 
        
Home       Members    Calendar    Who's On


Add to briefcase 12»»

Split integer valuefrom decimal valye Expand / Collapse
Author
Message
Posted Monday, July 07, 2008 5:45 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, September 29, 2010 3:02 AM
Points: 89, Visits: 53
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
Post #529177
Posted Tuesday, July 08, 2008 5:16 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, September 17, 2012 8:24 AM
Points: 1, Visits: 21
Function floor() does not work?
Post #529900
Posted Tuesday, July 08, 2008 5:31 AM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, September 29, 2010 3:02 AM
Points: 89, Visits: 53
Thanks,
It is working
Post #529911
Posted Tuesday, July 08, 2008 2:21 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, May 22, 2013 8:23 AM
Points: 323, Visits: 2,007
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.



Post #530358
Posted Tuesday, July 08, 2008 2:40 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 7:36 PM
Points: 32,931, Visits: 26,820
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
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #530365
Posted Tuesday, July 08, 2008 10:18 PM
SSC Journeyman

SSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC JourneymanSSC Journeyman

Group: General Forum Members
Last Login: Wednesday, September 29, 2010 3:02 AM
Points: 89, Visits: 53
Hi,
round function not gives proper output
floor is right.
Post #530475
Posted Tuesday, July 08, 2008 10:53 PM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 7:36 PM
Points: 32,931, Visits: 26,820
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
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #530482
Posted Wednesday, July 09, 2008 7:54 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, May 22, 2013 8:23 AM
Points: 323, Visits: 2,007
I'm sorry... I meant ROUND(YourValue, 0, 1)
I apologize for my lack of proof-reading.



Post #530824
Posted Wednesday, July 09, 2008 8:09 AM


SSC-Dedicated

SSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-DedicatedSSC-Dedicated

Group: General Forum Members
Last Login: Today @ 7:36 PM
Points: 32,931, Visits: 26,820
No problem and thanks for the feedback, Phil... I've made similar mistakes... just wanted to be sure...:)

--Jeff Moden
"RBAR is pronounced "ree-bar" and is a "Modenism" for "Row-By-Agonizing-Row".

First step towards the paradigm shift of writing Set Based code:
Stop thinking about what you want to do to a row... think, instead, of what you want to do to a column."

For better, quicker answers on T-SQL questions, click on the following...
http://www.sqlservercentral.com/articles/Best+Practices/61537/

For better answers on performance questions, click on the following...
http://www.sqlservercentral.com/articles/SQLServerCentral/66909/
Post #530843
Posted Monday, August 08, 2011 7:54 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Monday, March 18, 2013 2:47 AM
Points: 5, Visits: 39
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
Post #1156494
« Prev Topic | Next Topic »

Add to briefcase 12»»

Permissions Expand / Collapse