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 7, 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 8, 2008 5:16 AM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Tuesday, September 16, 2014 5:50 AM
Points: 1, Visits: 24
Function floor() does not work?
Post #529900
Posted Tuesday, July 8, 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 8, 2008 2:21 PM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 9:47 AM
Points: 358, Visits: 2,325
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 8, 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 @ 8:09 AM
Points: 35,216, Visits: 31,670
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #530365
Posted Tuesday, July 8, 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 8, 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 @ 8:09 AM
Points: 35,216, Visits: 31,670
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #530482
Posted Wednesday, July 9, 2008 7:54 AM


Old Hand

Old HandOld HandOld HandOld HandOld HandOld HandOld HandOld Hand

Group: General Forum Members
Last Login: Wednesday, September 17, 2014 9:47 AM
Points: 358, Visits: 2,325
I'm sorry... I meant ROUND(YourValue, 0, 1)
I apologize for my lack of proof-reading.



Post #530824
Posted Wednesday, July 9, 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 @ 8:09 AM
Points: 35,216, Visits: 31,670
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."

(play on words) "Just because you CAN do something in T-SQL, doesn't mean you SHOULDN'T." --22 Aug 2013

Helpful Links:
How to post code problems
How to post performance problems
Post #530843
Posted Monday, August 8, 2011 7:54 PM
Forum Newbie

Forum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum NewbieForum Newbie

Group: General Forum Members
Last Login: Sunday, May 26, 2013 9:06 PM
Points: 5, Visits: 40
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