Splunk Search

Why is strptime not returning results for a date field in my data?

ErikaE
Communicator

I have a time in the following format: 2015-08-11 16:31:25.973 in a field called "Last Modified On". The data comes from a log with several columns containing date time information.

What I'd like is to get a field at search-time that has just the date from the "Last Modified On" field, so I can group other fields by that date at search-time.

Here is my search:

host=* | eval test=strptime('Last Modified On',"%Y%m%d") | table test "Last Modified On"

The output is a table with blanks for all the test field values, and the date time in the Last Modified On field.

I have read other questions, but can't seem to find a similar example where strptime returns a blank for a string date. Is there a way to confirm that "Last Modified On" contains string data?

Tags (4)
0 Karma
1 Solution

maciep
Champion

I think you need to put the dashes in your format string, since they're in your last modified on field

eval test=strptime('Last Modified On',"%Y-%m-%d")

View solution in original post

maciep
Champion

I think you need to put the dashes in your format string, since they're in your last modified on field

eval test=strptime('Last Modified On',"%Y-%m-%d")

ErikaE
Communicator

Awesome. The answer was in epoch time but I was able to convert it with strftime.

LastModDate=strftime(strptime('Last Modified On',"%Y-%m-%d"),"%m %d %Y")
Get Updates on the Splunk Community!

Join Us for Splunk University and Get Your Bootcamp Game On!

If you know, you know! Splunk University is the vibe this summer so register today for bootcamps galore ...

.conf24 | Learning Tracks for Security, Observability, Platform, and Developers!

.conf24 is taking place at The Venetian in Las Vegas from June 11 - 14. Continue reading to learn about the ...

Announcing Scheduled Export GA for Dashboard Studio

We're excited to announce the general availability of Scheduled Export for Dashboard Studio. Starting in ...