Skip to content
Advertisement

Age from year and date column Netezza sql

I have data elements like ID; start_date; Birth_year. I want to calculate Age based on the birth_year column and start_date as shown in the AGE column.

enter image description here

I could only think of padding the birth year with ‘-01-01’ and then using that column to calculate Age.

Is there another efficient way to get Age from the birth year and start date in Netezza SQL?

Advertisement

Answer

Use the extract SQL function to get the year from start_date and do the age calcuation

E.g

will give


An alternative method to get more detailed age would be to use the Netezza ‘age’ SQL function

which will result in

User contributions licensed under: CC BY-SA
2 People found this is helpful
Advertisement