format of decimal

  • 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

  • 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.

    Change is inevitable... Change for the better is not.


    Helpful Links:
    How to post code problems
    How to Post Performance Problems
    Create a Tally Function (fnTally)

  • 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

  • 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?

    If you haven't even tried to resolve your issue, please don't expect the hard-working volunteers here to waste their time providing links to answers which you could easily have found yourself.

Viewing 4 posts - 1 through 3 (of 3 total)

You must be logged in to reply to this topic. Login to reply