Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: String to Date Conversion

  1. #1
    Join Date
    Jun 2014
    Posts
    24

    Default String to Date Conversion

    Hi,

    I want to do the String to Date Conversion. Let me explain about the requirement.

    A output field, entry_date, should have the extracted data mentioned in the input file name. Input filename is like "ABCD_EFG_HJK_20140408.csv". I have got the numbers in the output field, its in the string format. Now, I want it to be converted into Date format as dd/mm/yyyy. Can some body please help on this.

    Regards,
    Sandeep
    Last edited by sandeepcvk; 06-10-2014 at 12:41 AM.

  2. #2
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Two conversions are necessary: At first from String to Date using format string yyyyMMdd, then from Date to String using dd/MM/yyyy.
    You can use a Select Values step (tab "Meta-Data") to convert if you don't see any other way.
    So long, and thanks for all the fish.

  3. #3
    Join Date
    Jun 2014
    Posts
    24

    Default

    Thanks for your suggestion. It works with proper output. Once query I have, when selecting a column in Select Value step; can we have the same value under both the tabs in Select Value step (Select & Alert and Metadata tabs). When I select under only Metadata tab, I get the error as " Couldn't find field 'DATE' in row!. To avoid this error, i had to add extra select value step before the Output file step.

    Any suggestion on this concern?

    Thanks,
    Sandeep

  4. #4
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    Typically you will use tab "Select & Alter" to select, reorder and rename a subset of the available fields.
    If you make use of this tab, you must include all fields you want to show up downstream, even though you might have them configured for type conversion on the "Meta-Data" tab.
    Type conversion will be carried out last, meaning you must use the new names (in case you renamed fields) and you can't convert dropped fields.
    Generally, Select Values is executed tab by tab from left to right, as if it were three separate transformation steps.
    Last edited by marabu; 06-10-2014 at 01:11 PM. Reason: typo
    So long, and thanks for all the fish.

  5. #5
    Join Date
    Jun 2014
    Posts
    24

    Default

    Agree with your comment. But, I am facing is when I specify the field in both the tabs (Select & Alter and Metadata). I get the error "Couldn't find field 'DATE' in row!". As you mentioned, in case i have renamed the field name. I should take the renamed field name in the Metadata. But, that renamed field name will not be available in the list. so, using the field name in the same select value step under Select & Alter and Metadata gives me that error

  6. #6
    Join Date
    Jun 2012
    Posts
    5,534

    Default

    You mean, you get that error while designing your transformation? Well, I don't.
    If it's a runtime error, you should build a simple test case and attach it, so we can reproduce the error.
    And state your Kettle version, please.
    So long, and thanks for all the fish.

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •  
Privacy Policy | Legal Notices | Safe Harbor Privacy Policy

Copyright © 2005 - 2019 Hitachi Vantara Corporation. All Rights Reserved.