We are celebrating the 10-year anniversary of the Alteryx Community! Learn more and join in on the fun here.
Start Free Trial

Alteryx Designer Desktop Discussions

Find answers, ask questions, and share expertise about Alteryx Designer Desktop and Intelligence Suite.
SOLVED

Calculate Age from In-Database

AJ-CH
8 - Asteroid

Hello Fellows, 

I am looking for the code for putting in Formula tool of In-DB to calculate the age in years format. 

 

Any help will greatly appreciated. Thanks in advance!!!

 

6 REPLIES 6
scottj
Alteryx Alumni (Retired)

Try  DATEDIFF ( year, "DOB field" , GETDATE())

Scott Jones
Strategic Sales Engineer
Alteryx, Inc.
JoshKushner
12 - Quasar
Try this out! DateTimeDiff([End Date], [Start Date],"year")

I tried using the DATEDIFF method in IN-DB Formula and it doesnt work for me, is there any other method to calculate age in the IN-DB formula tool

Thableaus
17 - Castor
17 - Castor

@atamagaii_enginia 

 

In-DB functions are dependent on your database syntax and library of functions.

In SQL Server and MySQL, it's DATEDIFF

In Oracle, you can subtract one date minus the other. E.g. -> 2018-01-18 - 2018-01-03

What's your database?

 

Cheers,

Its Oracle, so if i want to calculate the age through in-db formula tool , what query should i use?

 

I was able to do in Sql through Sysdate but getdate in IN-db formula is creating issues

Thableaus
17 - Castor
17 - Castor

@atamagaii_enginia 

 

 

TRUNC((SYSDATE - TO_DATE(DOB, 'YYYY-MM-DD'))/ 365.25)

 

Cheers, 

Labels
Top Solution Authors