Age Formula Baserow

Hi All,

I’m using Cloud Hosted.

I have a Date column which is called ‘Date of Birth’, I am trying to create an Age column and use the today() formula to get the age of each person using the Date of Birth. I cannot get this to work for various reasons - keep getting errors about the expected result being a date field rather than text or number.

Would someone be able to help me with this? I feel like I’m missing something super simple but can’t quite figure it out at the moment. I just want to use the Date of Birth to generate the Age in a separate column.

On another note, It would be useful if I could someone how use the age data to group rows by age bands e.g. those aged 18-24, 25-34, 35-54? Any ideas on how I can achieve this without minimal user input?

Thanks!

Hey @NicoR93, sure, try using this formula:

date_diff('yy', field('your_date_field'), today())

1 Like

You can add another formula and then group by its results:
if(and(field('Age') >= 18, field('Age') <= 24), '18-24', if(and(field('Age') >= 25, field('Age') <= 34), '25-34', if(and(field('Age') >= 35, field('Age') <= 54), '35-54', 'Age out of range')))

Is it what you’re looking for?

1 Like

Thank you so much that’s worked perfectly!

1 Like

If I am correct this makes them all 1 year older on 1/1 every year - right?
Is there a solution to change age on the birthdays?

Hi there! In the Age field, we used the today function, which updates every 10 minutes. This means both the Age field and the Formula field will always stay up to date.

Is there a solution to change age on the birthdays?
In this example, the age is calculated automatically using the date of birth and current date (today function).