How can I create a new atribute that show the age of people to a specific date?

Tdragi13
Tdragi13 New Altair Community Member
edited November 5 in Community Q&A
I need to create a new atribute, and show the age of the people of my database on a specific date? Can I do it with date operators?

Best Answer

  • Caperez
    Caperez Altair Community Member
    Answer ✓
    Hi @Tdragi13
    Please read this Thread

    Calculating time difference in days between two dates — RapidMiner Community

    You can use the Generate Attribute operator and then the function datediff(), e.g

    date_diff([Date],date_parse_custom("04.03.2021","dd.MM.yyyy"))
    where [Date] is your Datetime attibute (Colum)

    Remember that datediff function return the difference in miliseconds, so if you need the difference in days or other units you need to divide it e.g
    (date_diff([Date],date_parse_custom("04.03.2021","dd.MM.yyyy")))*1.15741e-8 for days

    regards


Answers

  • Caperez
    Caperez Altair Community Member
    Hi @Tdragi13,

    Do you need to calculate the age based in a datetime atribute from database?

    Regards
  • Tdragi13
    Tdragi13 New Altair Community Member
    Hi @ceaperez
    I need to generate a new discrete attribute, which indicates the age of people on a specific date. And for this, I need to use date operators. 

    The data must be taken from a column call "Date of birth" from the database.

    So for example. I need a new attribute which shows me the age of the people up to the 4/03/2021

    Thankss :smile: 
  • Caperez
    Caperez Altair Community Member
    Answer ✓
    Hi @Tdragi13
    Please read this Thread

    Calculating time difference in days between two dates — RapidMiner Community

    You can use the Generate Attribute operator and then the function datediff(), e.g

    date_diff([Date],date_parse_custom("04.03.2021","dd.MM.yyyy"))
    where [Date] is your Datetime attibute (Colum)

    Remember that datediff function return the difference in miliseconds, so if you need the difference in days or other units you need to divide it e.g
    (date_diff([Date],date_parse_custom("04.03.2021","dd.MM.yyyy")))*1.15741e-8 for days

    regards