Splunk Search

How to convert date

hank72
Path Finder

How to convert Windows lastLogonTimestamp from this format 07:17.45 PM, Fri 09/30/2022 to 09/30/2022 19:17:45

Thank you

 

 

Labels (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @hank72,

sorry, my error:

| eval lastLogonTimestamp=strftime(strptime(lastLogonTimestamp,"%I:%M.%S %p, %a %m/%d/%Y"),"%m/%d/%Y %H:%M:%S")

Ciao.

Giuseppe

View solution in original post

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @hank72,

to convert a date, you have to transform it in epochtime (using strptime) and then again the output format (using strftime) in an eval command, something like this:

| eval lastLogonTimestamp=strftime(strptime(lastLogonTimestamp,"%H:%M.%S %p, %a %m/%d/%Y"),"%m/%d/%Y %H:%M:%S")

 for more infos see at 

https://docs.splunk.com/Documentation/SCS/current/SearchReference/DateandTimeFunctions#strptime.28.2...

https://docs.splunk.com/Documentation/SCS/current/SearchReference/DateandTimeFunctions#strftime.28.2...

Ciao.

Giuseppe

hank72
Path Finder

Thank you Giuseppe, however my time is still showing up as 07:17:45 and not as 19:17:45

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @hank72,

sorry, my error:

| eval lastLogonTimestamp=strftime(strptime(lastLogonTimestamp,"%I:%M.%S %p, %a %m/%d/%Y"),"%m/%d/%Y %H:%M:%S")

Ciao.

Giuseppe

0 Karma

hank72
Path Finder

Thank you!  It worked!

 

0 Karma

gcusello
SplunkTrust
SplunkTrust

Hi @hank72,

good for you, see next time!

Ciao and happy splunking

Giuseppe

P.S.: Karma Points are appreciated 😉

Get Updates on the Splunk Community!

Threat Hunting Unlocked: How to Uplevel Your Threat Hunting With the PEAK Framework ...

WATCH NOWAs AI starts tackling low level alerts, it's more critical than ever to uplevel your threat hunting ...

Splunk APM: New Product Features + Community Office Hours Recap!

Howdy Splunk Community! Over the past few months, we’ve had a lot going on in the world of Splunk Application ...

Index This | Forward, I’m heavy; backward, I’m not. What am I?

April 2024 Edition Hayyy Splunk Education Enthusiasts and the Eternally Curious!  We’re back with another ...