Splunk Search

Help to convert date using strftime

Marco_Develops
Path Finder

Currently I have a field holding a Julian date. I am trying to convert it using strftime but i'm having issues.

 

Date = 2022.091

Current query:

 

 

index = * | eval ConvertedDate = strftime(DATE,"%Y.%j")| table ConvertedDate

 

 

 

Ideally I would like to get an output like 04/03/2022

 

Thank you,

Marco

Labels (3)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

The strftime function converts an epoch timestamp (integer) into a human-readable string.  Use the strptime function to convert a datetime string into epoch form.

 

index = * 
| eval ConvertedDate = strftime(strptime(DATE,"%Y.%j"), "%m/%d/%Y")
| table ConvertedDate

 

 

---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

The strftime function converts an epoch timestamp (integer) into a human-readable string.  Use the strptime function to convert a datetime string into epoch form.

 

index = * 
| eval ConvertedDate = strftime(strptime(DATE,"%Y.%j"), "%m/%d/%Y")
| table ConvertedDate

 

 

---
If this reply helps you, Karma would be appreciated.

Marco_Develops
Path Finder

@richgalloway This worked. Thank you for your time and explanation . 

-Marco

0 Karma
Get Updates on the Splunk Community!

Introducing Splunk Enterprise 9.2

WATCH HERE! Watch this Tech Talk to learn about the latest features and enhancements shipped in the new Splunk ...

Adoption of RUM and APM at Splunk

    Unleash the power of Splunk Observability   Watch Now In this can't miss Tech Talk! The Splunk Growth ...

Routing logs with Splunk OTel Collector for Kubernetes

The Splunk Distribution of the OpenTelemetry (OTel) Collector is a product that provides a way to ingest ...