Calculate my age starting from my date of birth and comparing it to today's date

@Plankton @Timo @ulrich @thecoder2012

With kantu, is it possible to calculate my age starting from my date of birth and comparing it to today’s date? could someone explain to me how to make the macro code?

My date of birth: 15/05/1995 (May 15 1995)
Today: 09/10/2019 (October 09 2019)

How can I calculate my age ?

P.S… I added italian date format and english date format

Any suggestion please ?

Use Javascript in your Kantu with executeScript_sandbox or executeScript.

Hi thanks but it very hard for me this code

Can you provide me a code to do this please ?

{
  "Name": "test-birthday",
  "CreationDate": "2019-10-11",
  "Commands": [
    {
      "Command": "store",
      "Target": "1995/05/15",
      "Value": "birthday"
    },
    {
      "Command": "executeScript_Sandbox",
      "Target": "function getAge(dateString) {var today = new Date();var birthDate = new Date(dateString);var age = today.getFullYear() - birthDate.getFullYear();var m = today.getMonth() - birthDate.getMonth();if (m < 0 || (m === 0 && today.getDate() < birthDate.getDate())){age--;}return age;}return getAge(${birthday});",
      "Value": "age"
    },
    {
      "Command": "echo",
      "Target": "${age}",
      "Value": ""
    }
  ]
}
2 Likes

You’re wonderful, a genius, thanks the code works great, you’re a myth, thank you