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

format of decimal Expand / Collapse
Author
Message
Posted Wednesday, September 4, 2013 1:34 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Friday, December 19, 2014 12:10 PM
Points: 1,792, Visits: 3,262
I have a SSIS package, of attendance data. most of them is a whole number like absent days 5 days, or 100 days in a semester. But some of the elementarys we count by half days, so they may have total absent days like 10.5 days.

Because in the databsae the data type is a decimal(4,1), when I export to a flat file, I would like the whole number still shows whole number, like 20 days, I would like it shows 20 instead of 20.0. but still want those with half days like 10.5 shows like that format.

How can I do a conversion?

Thanks
Post #1491511
Posted Wednesday, September 4, 2013 3:24 PM


SSC-Dedicated

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

Group: General Forum Members
Last Login: Today @ 2:36 PM
Points: 35,776, Visits: 32,448
sqlfriends (9/4/2013)
I have a SSIS package, of attendance data. most of them is a whole number like absent days 5 days, or 100 days in a semester. But some of the elementarys we count by half days, so they may have total absent days like 10.5 days.

Because in the databsae the data type is a decimal(4,1), when I export to a flat file, I would like the whole number still shows whole number, like 20 days, I would like it shows 20 instead of 20.0. but still want those with half days like 10.5 shows like that format.

How can I do a conversion?

Thanks


I guess I have to ask.... why do you want to build in an inconsistancy here?


--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 #1491550
Posted Wednesday, September 4, 2013 3:49 PM
SSCommitted

SSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommittedSSCommitted

Group: General Forum Members
Last Login: Friday, December 19, 2014 12:10 PM
Points: 1,792, Visits: 3,262
You are right, although I have some reason but I think maybe I should keep it consistent.

A derived question, U use dt_numeric precision 38, scale 1, when I export I expect 0.5. but why it shows
.5 the leading 0 is trimmed off.

Any idea?

Thanks
Post #1491560
Posted Wednesday, September 4, 2013 11:39 PM


SSCertifiable

SSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiableSSCertifiable

Group: General Forum Members
Last Login: Today @ 12:24 AM
Points: 5,317, Visits: 12,355
sqlfriends (9/4/2013)
You are right, although I have some reason but I think maybe I should keep it consistent.

A derived question, U use dt_numeric precision 38, scale 1, when I export I expect 0.5. but why it shows
.5 the leading 0 is trimmed off.

Any idea?

Thanks


0.5, 00.5, .5 and .50000 are all the same, numerically - the leading and trailing zeros are insignificant. Why does it matter?



Help us to help you. For better, quicker and more-focused answers to your questions, consider following the advice in this link.

When you ask a question (and please do ask a question: "My T-SQL does not work" just doesn't cut it), please provide enough information for us to understand its context.

It is better to keep your mouth shut and appear stupid than to open it and remove all doubt. (Mark Twain)
Post #1491625
« Prev Topic | Next Topic »

Add to briefcase

Permissions Expand / Collapse