Re-arrainge a character field

  • Jeff

    It just so happens, I needed to use this today to ensure all dates were extracted the same way that had two different formats, MM/DD/YYYY or YYYY/MM/DD as the flat file was created from two different sources that I have no control over. The issue being, in order to produce a file for upload into the warehouse being utilized, the date had to be in the YYYY-MM-DD format. I adapted your post to this 'REPLACE(CONVERT(CHAR(10),CAST(dob AS DATETIME),111), '/', '-')' saving myself a case statement with numererous cast statements.

    Thanks Again

    Marvin Dillard
    Senior Consultant
    Claraview Inc

  • Outstanding! Nothing like positive feeback to start the day! Thanks, Marvin!

    --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)

Viewing 2 posts - 16 through 16 (of 16 total)

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