Your achievements

Level 1

0% to

Level 2

Tip /
Sign in

Sign in to Community

to gain points, level up, and earn exciting badges like the new
Bedrock Mission!

Learn more

View all

Sign in to view all badges


Script to calculate age from first 6 digits of a 10 digit number (DDMMYYXXXX)


Level 3

I have a  "numeric field" which will contain a 10 digit number; the fist 4 digits being the date of birth (DDMMYY). 

I would really like to have another field where the DOB is automatically calculated from this. I'd appreciated any help - I have pretty much zero knowledge of scripting.

1 Accepted Solution


Correct answer by

ok, I think I can see the problem. CHI is a numeric field and not a text field. Therefore the CHId is not a string but a digital number - that means that "0101191234" is actually a numeric value of 101191234. That cannot be dismantled with substring.

Change the CHI field to textfield and then try again.I tested your fields with the correct type and then it works:


To force format and length of CHI limit max characters


Display and validation patterns text{9999999999} and error on validation





View solution in original post

0 Replies


Level 3

Thanks kprokopi - the script works fine on the form you sent. But when I copy and past those 3 fields to my own form, it does't work and I get a huge number!






I also looks like the date format is different in the 2nd box - I don't why this could be, as I just copied across from your form to mine!


Edit: this should have been a reply to the other thread about the 2 date fields, sorry! I've commented there also. 


Level 4
The screenshot shows that the 2 date fields show different formatting depending n locale and formatting settings - you need to have them the same