US and Worldwide: +1 (866) 660-7555
Results 1 to 5 of 5

Thread: How to convert Date from yyyy-mm-dd to mm/dd/yy

  1. #1

    Default How to convert Date from yyyy-mm-dd to mm/dd/yy

    Hello,

    We have a date field coming in from XML file in the form of yyyy-mm-dd and need to reformat it to mm/dd/yy. The built in date formatter does not seem to handle this. Anyone know of a solution?
    Thanks

  2. #2
    Join Date
    Apr 2008
    Posts
    2,633

    Default

    Are you wanting to store the date field in a DB, or output it to a text file (or string field in a DB)?

    If you're putting it in a DB, then don't worry about it. It's parsing the date, and storing the value as a date object. Just put the date object into the DB and it will be fine.

    If you're outputting to a file, then in the File output box (Excel, or Text), in the fields tab, format the date the way you want.

    If you're outputting to a string field in a DB, then you need to use the select values step to change the meta data to a string, and format it when you're converting it to a string.

  3. #3

    Default Thank you...

    Thank you for the response. Putting the data in an excel cell. The built-in formater did NOT work so we wrote a little java to parse it....

    var enteredwrkYY = substr(EnteredDate,2,2); //parse year
    var enteredwrkMM = substr(EnteredDate,5,2); //parse month
    var enteredwrkDD = substr(EnteredDate,8,2); //parse day
    var newEnteredDate = enteredwrkMM + '/' + enteredwrkDD + '/' + enteredwrkYY;

  4. #4
    Join Date
    Apr 2008
    Posts
    2,633

    Default

    No need to use java to parse it - PDI will already do that.

    Tell your XML Input that the field is a Date with format yyyy-MM-dd (Case *IS* important here)
    Tell your Excel output that the field is a Date with format MM/dd/yy (Case *IS* important here)

  5. #5

    Default

    Gutlez,
    Thank you SOoooo much for clarifying the syntax. Works like a charm!

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •