Getting Data In

Time Format conversion using strptime

asarolkar
Builder

I have a date timestamp coming in as a string in this format
2012-08-08 11:29:03.727000000

This is extracted as a field called createDtTimeStamp

I want to simply extract JUST the date part from this field and use the following query:

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

This does not seem to work. Any ideas why ?

1 Solution

Ayn
Legend

Well your format string seems to be off. %b is "Locale’s abbreviated month name." which does not match 2012-08-08. You'll likely want something like

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

View solution in original post

Ayn
Legend

Well your format string seems to be off. %b is "Locale’s abbreviated month name." which does not match 2012-08-08. You'll likely want something like

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

asarolkar
Builder

worked like a charm !

0 Karma
Get Updates on the Splunk Community!

Stay Connected: Your Guide to May Tech Talks, Office Hours, and Webinars!

Take a look below to explore our upcoming Community Office Hours, Tech Talks, and Webinars this month. This ...

They're back! Join the SplunkTrust and MVP at .conf24

With our highly anticipated annual conference, .conf, comes the fez-wearers you can trust! The SplunkTrust, as ...

Enterprise Security Content Update (ESCU) | New Releases

Last month, the Splunk Threat Research Team had two releases of new security content via the Enterprise ...