cancel
Showing results for
Did you mean:
Helper I

## Calculating age from birth date and current date using Workflow Definition Language expressions

If I have a date of birth (from a Microsoft form question) and have inserted it into an Excel table row, how would I calculate age using a Workflow Definition Expression which would be placed in an Excel table column beside the one for date of birth?

1 ACCEPTED SOLUTION

Accepted Solutions
Helper I

I did manage to get age using ticks for the birthdate (from Microsoft Form field) and utcNow.  After dividing by a couple of constants I was able to get age as a float.

Expression is:  div(div(sub(variables('Today'),variables('Birthdate')),864000000000),365.25)

Variable Today is "ticks(utcNow())"

Variable Birthdate is "
ticks(body('Get_response_details')?['rde329303c5a04b32b9b9f35a0564400e']) based on Microsoft Form response field.

At the end of the day I did not go ahead with the calculation as the result is not dynamic, i.e. result does not change if someone has a birthday.

2 REPLIES 2
Community Support

Hi @ras1000,

Currently it is not possible to use a datediff function in flow to count days between two days. There is a similar request on Flow Ideas Forum, please vote the idea at here:

https://powerusers.microsoft.com/t5/Flow-Ideas/workflow-definition-language-needs-to-be-expanded/idi...

Best regards,

Mabel Mao

Community Support Team _ Mabel Mao
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Helper I

I did manage to get age using ticks for the birthdate (from Microsoft Form field) and utcNow.  After dividing by a couple of constants I was able to get age as a float.

Expression is:  div(div(sub(variables('Today'),variables('Birthdate')),864000000000),365.25)

Variable Today is "ticks(utcNow())"

Variable Birthdate is "
ticks(body('Get_response_details')?['rde329303c5a04b32b9b9f35a0564400e']) based on Microsoft Form response field.

At the end of the day I did not go ahead with the calculation as the result is not dynamic, i.e. result does not change if someone has a birthday.

Announcements

#### Launching new user group features

Learn how to create your own user groups today!

#### Community & How To Videos

Check out the new Power Platform Community Connections gallery!

#### Microsoft 365 Collaboration Conference | December 7–9, 2021

Join us, in-person, December 7–9 in Las Vegas, for the largest gathering of the Microsoft community in the world.

Top Solution Authors
Top Kudoed Authors
Users online (3,229)