Other Usage

Is there a way to calculate Age by Date (Older than 50 years)?

peining
Observer

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?

Tags (1)
0 Karma

VatsalJagani
SplunkTrust
SplunkTrust

@peining - Try this:

| eval APPLICANT_BIRTH_YEAR = substr(APPLICANT_DOB, 2, 2)

 

Kindly upvote if you find it useful!!!

0 Karma

yeahnah
Motivator

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

0 Karma

SanjayReddy
SplunkTrust
SplunkTrust

Hi @peining 

Unfortunately strptime can not convert years beofre 1971,

SanjayReddy_0-1682477186822.png

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... 

0 Karma
Get Updates on the Splunk Community!

Upcoming Webinar: Unmasking Insider Threats with Slunk Enterprise Security’s UEBA

Join us on Wed, Dec 10. at 10AM PST / 1PM EST for a live webinar and demo with Splunk experts! Discover how ...

.conf25 technical session recap of Observability for Gen AI: Monitoring LLM ...

If you’re unfamiliar, .conf is Splunk’s premier event where the Splunk community, customers, partners, and ...

A Season of Skills: New Splunk Courses to Light Up Your Learning Journey

There’s something special about this time of year—maybe it’s the glow of the holidays, maybe it’s the ...