Hitachi Vantara Pentaho Community Forums
Results 1 to 5 of 5

Thread: Converting Dates (String) to Date for age calculation

  1. #1

    Default Converting Dates (String) to Date for age calculation

    Hi. Im pretty new to pentaho spoon and was searching around for hours trying all sorts of things but to no avail.

    Have a dataset with a date (DOB) in the form of a string (27-Jul-1995) and I am trying to use 'Get System Info" and system date(fixed) to get the Age of a person and insert it as a column (Some clue of what I'm doing are in the pictures below). I know nothing about Java or what steps i should take so some help would be greatly appreciated. Thanks much!

    Name:  Untitled.jpg
Views: 145
Size:  16.9 KB

    Name:  2123.jpg
Views: 156
Size:  25.5 KB

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

    Default

    Use a "Select Values" step inline somewhere after extract_customers.ar to convert the string field to a date field with format dd-MMM-yyyy (As per https://docs.oracle.com/javase/8/doc...ateFormat.html )

    Does that help?

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

    Default Calculating age from Date-Of-Birth

    Me fooling around with Java 8 ...
    Attached Files Attached Files
    So long, and thanks for all the fish.

  4. #4

    Default

    Quote Originally Posted by gutlez View Post
    Use a "Select Values" step inline somewhere after extract_customers.ar to convert the string field to a date field with format dd-MMM-yyyy (As per https://docs.oracle.com/javase/8/doc...ateFormat.html )

    Does that help?
    The problem is that I'm not sure which step allows me to do so. What i want is the age to be specific.

    E.g:
    DOB > Gives me a STRING
    ''Get System Info" - system date(fixed) > Gives me a TIMESTAMP

    Age (What i want in a new column) = system date(fixed) - DOB

  5. #5
    Join Date
    Jun 2016
    Posts
    181

    Default

    Marabu example gives you exactly what u need. Just insert "User Defined Java Expression" step with this expression on the path (afer you read from source) and u'll have new, ready field "Age" ready to use.


    Quote Originally Posted by XswordcraftX View Post
    The problem is that I'm not sure which step allows me to do so. What i want is the age to be specific.

    E.g:
    DOB > Gives me a STRING
    ''Get System Info" - system date(fixed) > Gives me a TIMESTAMP

    Age (What i want in a new column) = system date(fixed) - DOB

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.