Hi All!
I have a field in my data which represents DOB in a YYYYMMDD format. I'm trying to compare that DOB Timestamp with another Timestamp field which represents the time the event was created. Same format YYYYMMDD. What I'm trying to determine is how old someone is when they were tested.
I've attempted to convert them both to epoch using eval, but it appears to only work on the first field.
index=test | eval DOB = strftime(Date_of_Birth, "%Y%m%d") | eval ICD = strftime(Instance_Creation_Date, "%Y%m%d") | eval diff = ('DOB' - 'ICD')
Anyone have a pointer?
As always. Thanks!
For the direction you're looking to convert, I think you want strptime
rather than strftime
.
The strftime function won't work for any data prior to the start of epoch in 1970. To do this properly, you will have to do your math discreetly. Check the accepted answer here for an approach.
You'll have to massage the RegEx a bit, because you don't have any separators between your date components. Something like this should work: rex field=Date_Of_Birth "(?<y>\d{4})(?<m>\d{2})(?<d>\d{2})"