Do not input private or sensitive data. View Qlik Privacy & Cookie Policy.
Skip to main content

Announcements
Qlik GA: Multivariate Time Series in Qlik Predict: Get Details
cancel
Showing results for 
Search instead for 
Did you mean: 
slim025
Contributor
Contributor

Calculate the age from the current date and the date of birth

Hello;

I wish I calculate the age of a person from his date of birth and compared to the current date?
I've done me is this:

TalendDate.diffDate(TalendDate.parseDate("dd-MM-yyyyy","11-08-2013"),TalendDate.parseDate("dd-MM-yyyyy","20-01-2000"),"dd")

I'd like it to be dynamic I do not know if we can do that.??
TalendDate.diffDate(TalendDate.parseDate("dd-MM-yyyyy","TalendDate.getCurrentDate()"),TalendDate.parseDate("dd-MM-yyyyy","row6.dateNaiss"),"dd")

But it shows me an error: Type mismatch: can not convert long to float
I also tried it
test.agePatient==null?(String.valueOf((TalendDate.diffDate(TalendDate.getCurrentDate(), row6.dateNaiss,"yyyy"))).toString():test.agePatient);
and it also
test.agePatient==null? String.((TalendDate.diffDate(TalendDate.getCurrentDate(),row6.dateNaiss,"yyyy"))).(TalendDate.parseDate(test.agePatient));
But I still have errors
Can you help me please?
Regards.
Labels (2)
14 Replies
alevy
Specialist
Specialist

Try to understand what the functions actually do so you can pass the correct parameters to them.
Assuming dateNaiss is a Date not a String: TalendDate.diffDateFloor(TalendDate.getCurrentDate(),row6.dateNaiss,"yyyy")
Your type mismatch error is coming from somewhere else in your job. Look at the Code tab to see exactly where.
slim025
Contributor
Contributor
Author

Hi,
thank you for responding so quickly 0683p000009MACJ.png
look, in my MySQL database, I have a date of birth that is like this: dd-mm-yyyy, Example 09-11-1984. and I would like to calculate the age of the person using the current date.
alevy
Specialist
Specialist

If it's a Date in MySQL and you're reading it into Talend as a Date then the format in which it's displayed is irrelevant and the expression I gave you will do what you want.
slim025
Contributor
Contributor
Author

thanks for your answer but, i didn't understand you, please can you give me a concret exemple?
Regards
alevy
Specialist
Specialist

What didn't you understand? Just use the expression I gave you...
slim025
Contributor
Contributor
Author

i try to do your expression, but, i have a mismatch: can not convert long to float.
Help me please
Anonymous
Not applicable

Hi,
It is helpful to give us your job screenshots so that we can get your current job situation.
Best regards
Sabrina
slim025
Contributor
Contributor
Author

Hi,
Attached my screen printed job talend
Best regards,
Slim
slim025
Contributor
Contributor
Author

Hi,
Attached my screen printed job talend
Best regards,
Slim