# Compute the age based on the date of birth - Pipedrive x Make

Hi. We have a date of birth and age field in Pipedrive. We want to auto-compute the age based on the date of birth. Can someone share a guide? Thank you

Hi @aamag

You can use the below formula if your date is same like below â€ś12-07-1993â€ť .
{{get(split(formatDate(now; â€śMM-DD-YYYYâ€ť); â€ś-â€ť); 3) - get(split(â€ś12-07-1993â€ť; â€ś-â€ť); 3)}}

2 Likes

Instead of split, you can also do this:

`{{formatDate(now; "YYYY") - formatDate(parseDate("1994-02-14"; "YYYY-MM-DD"); "YYYY")}}`

# Explanation

### Step 1

Parse input date string into a date type using the Date Format Tokens

`{{parseDate("1994-02-14"; "YYYY-MM-DD")}}`

### Step 2

Get year of birth passing step 1 into `formatDate` function

`{{formatDate(parseDate("1994-02-14"; "YYYY-MM-DD"); "YYYY")}}`

### Step 3

Get current year using `formatDate`

`{{formatDate(now; "YYYY")}}`

### Step 4

Combine all steps, use `-` to subtract year of birth from current year

`{{formatDate(now; "YYYY") - formatDate(parseDate("1994-02-14"; "YYYY-MM-DD"); "YYYY")}}`

# Output bundle

4 Likes

Hi @samliew Thank you so much for the detailed explanation. Though can you let me know how to get to that point? From Pipedrive trigger.

You just have to put this formula in whichever field you want to map the age into, and replace `1994-02-14` in my example with the variable from where youâ€™re storing the date of birth string, and change the format `YYYY-MM-DD` to match the format of the date of birth input.

If you need more help, perhaps exporting the blueprint might help others replicate the issue to be able to answer your question.

At the bottom of the scenario editor, you can click on the three dots to find the Export Blueprint menu item.

Uploading it here will look like this:

blueprint.json (123.4 KB)

2 Likes

blueprint (1).json (72.8 KB)

Hi @samliew Thanks for explaining further. Hereâ€™s the blueprint. Can you please check? Thank you.

Hi @samliewmake Thanks for explaining further. Hereâ€™s the blueprint. Can you please check? Thank you.
blueprint (1).json (72.8 KB)

From your blueprint, I can see that you havenâ€™t changed the example hard-coded/static date of birth to the variable coming from your trigger

Could you please make the change first, then provide a screenshot of the fields in your modules, and/or provide the output bundles of the module by running the scenario, then clicking here and copying the contents:

This will allow others to better assist you. Thanks!

2 Likes

Hi @samliew Sorry for getting back late.
I just have a clarification on this initial set up you shared. Are you saying we should have a Year or birth and current year field in Pipedrive for this to work? We donâ€™t have those fields and I think thatâ€™s too manual to input for the client.

@samliew This is still aamag. Iâ€™m just using another account.

No, variables 1-3 are just showing you each step. The last one is all combined - just do that.

2 Likes

blueprint (2).json (72.9 KB)

Hi @samliew hereâ€™s an updated trial. Can you please check? Thank you

The age field looks correct, but I donâ€™t have a Pipedrive connection, so I canâ€™t test your scenario.

Your error message seems to be unrelated to the question. You should create a new question and add your screenshots of the modules, input/output bundles there.

2 Likes

Hi @samliew Got it. Thank you so much for the help!

2 Likes