Hitachi Vantara Pentaho Community Forums
Results 1 to 6 of 6

Thread: Age

  1. #1
    Join Date
    Feb 2011
    Posts
    240

    Default Age

    Hi,

    if I've the field "data_nascita", how can I calculate the age with kettle?

    Thanks

    Mariarita

  2. #2
    Join Date
    Mar 2011
    Posts
    257

    Default

    current year - year in the birthdate... with some date functions

    grtz,
    Hans

  3. #3
    Join Date
    Nov 2008
    Posts
    271

    Default

    1) input step (whatever)
    2) Use Get System info step to get the current date

    3a) Calculator step: extract the year from both birth date and today; calculate the difference

    3b) Formula step: use the DATEDIF formula (format "y")

    HTH
    Andrea Torre
    twitter: @andtorg

    join the community on ##pentaho - a freenode irc channel

  4. #4
    Join Date
    Feb 2011
    Posts
    240

    Default

    Hi,

    this is my tranformation:

    1) table input (I select the date birth field from the table)

    2) get system info (name = today, type = oggi 00:00:00)

    3) calculator:
    - new field = anno_today, calculation = Anno di data A, FieldA = today
    - new field = anno_nascita, calculation = Anno di data A, FieldA = DATA_NASC
    - new field = eta, calculation = A - B, FieldA = anno_today, FieldB = anno_nascita

    4) formula (new field = age, formula = datedif([DATA_NASC];[today];"m"), type of value= number, length = 2)

    5) table output (I want a table with field age)

    What is the error?

    thanks

    Mariarita

  5. #5
    Join Date
    Nov 2008
    Posts
    271

    Default

    No.
    3a) and 3b) are alternatives. Choose what you prefer: you either have to use calculator step or formula step. If you feel more comfortable there's also a third way, via Modified Java Script Value.

    Anyway, it seems to me that the calculator configuration you used should be fine, so drop point 4) and go straight to table output.

    Regards
    Andrea Torre
    twitter: @andtorg

    join the community on ##pentaho - a freenode irc channel

  6. #6
    Join Date
    Feb 2011
    Posts
    240

    Default

    thanks very much!!!

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.