Splunk Dev

Time_format_change_procedure

abid91
Engager

Hi Guys,
I am trying to create a use-case as " date when any single user was created in AD" it's done but I need to change time format to readable format, right now it coming like this "20170905133223.0Z" how can I convert it to as " 05-September-2017" I tried with eval command as follows but no effect in results.

search:| ldapsearch domain=default search="(objectClass=user)" | table displayName,whenCreated |eval epochtime=strptime(whenCreated, "%Y %m %d %H:%M:%S") | eval desired_time=strftime(epochtime, "%d/%m/%Y")
result: ABC|20170905133223.0Z
desired result: ABC|05-September-2017

Tags (1)
0 Karma
1 Solution

inventsekar
SplunkTrust
SplunkTrust

Please check -
search:| ldapsearch domain=default search="(objectClass=user)" |eval epochtime=strptime(whenCreated, "%Y%m%d%H%M%S.%1N%Z") | eval desired_time=strftime(epochtime, "%d/%m/%Y") | table displayName whenCreated desired_time

thanks and best regards,
Sekar

PS - If this or any post helped you in any way, pls consider upvoting, thanks for reading !

View solution in original post

inventsekar
SplunkTrust
SplunkTrust

Please check -
search:| ldapsearch domain=default search="(objectClass=user)" |eval epochtime=strptime(whenCreated, "%Y%m%d%H%M%S.%1N%Z") | eval desired_time=strftime(epochtime, "%d/%m/%Y") | table displayName whenCreated desired_time

thanks and best regards,
Sekar

PS - If this or any post helped you in any way, pls consider upvoting, thanks for reading !

abid91
Engager

Yes! it's working thank you

0 Karma

gcusello
SplunkTrust
SplunkTrust

HI abid91,
try something like this

| ldapsearch domain=default search="(objectClass=user)" 
| eval whenCreated=strftime(strptime(whenCreated, "%Y %m %d %H:%M:%S"), "%d/%m/%Y")
| table displayName,whenCreated 

Check the original time format of whenCreated
Bye.
Giuseppe

0 Karma

abid91
Engager

its showing blank values in whenCreated filed.

0 Karma
Get Updates on the Splunk Community!

Splunk App for Anomaly Detection End of Life Announcement

Q: What is happening to the Splunk App for Anomaly Detection?A: Splunk is officially announcing the ...

Transforming Financial Data into Fraud Intelligence

Every day, banks and financial companies handle millions of transactions, logins, and customer interactions ...

How to send events & findings from AWS to Splunk using Amazon EventBridge

Amazon EventBridge is a serverless service that uses events to connect application components together, making ...