I am trying to calculate birth year and age, based on birthdate.
The following works, but only for dates within the last 50 years. There seems to be no output for birthdays > 50 years old.
eval APPLICANT_BIRTH_YEAR = strftime(strptime(APPLICANT_DOB, "%Y-%m-%d %H:%M:%S"), "%y")
Is there a way to do this properly?
@peining - Try this:
| eval APPLICANT_BIRTH_YEAR = substr(APPLICANT_DOB, 2, 2)
Kindly upvote if you find it useful!!!
Hi @peining
If the applicant DOB is provided as a string value anyway, then simply extract it from the string. For example
| makeresults
| eval APPLICANT_DOB="1882-06-22 00:00:00"
,APPLICANT_BIRTH_YEAR=replace(APPLICANT_DOB, "-.*", "")Hope that helps
Hi @peining
Unfortunately strptime can not convert years beofre 1971,
However, you can try solution provided by @ITWhisperer , for similar case ,Hope folliowing post might help
https://community.splunk.com/t5/Splunk-Search/Problem-with-Date-Time-Manipulation-for-date-in-the-ye...