Getting Data In

How to convert date format?

dhiraj
Loves-to-Learn Lots

Hi ,

In splunk query I need to convert date format as below .

Current format - 07/09/23

Required Format : 2023-09-07

Labels (1)
0 Karma

richgalloway
SplunkTrust
SplunkTrust

Use the strptime function to convert the current format into epoch form then use strftime to convert that into the required format.  The two functions can be used in a single eval.

| eval timefield=strftime(strptime(timefield, "%d/%m/%y"), "%Y-%m-%d")

 

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

gcusello
SplunkTrust
SplunkTrust

Hi @dhiraj ,

you have to use the eval command with the strftime and strptime options, like this:

| eval new_date=strftime(strptime(date,"%d/0m/%y"),"%Y-%m-%d")

Ciao.

Giuseppe

Get Updates on the Splunk Community!

AI for AppInspect

We’re excited to announce two new updates to AppInspect designed to save you time and make the app approval ...

App Platform's 2025 Year in Review: A Year of Innovation, Growth, and Community

As we step into 2026, it’s the perfect moment to reflect on what an extraordinary year 2025 was for the Splunk ...

Operationalizing Entity Risk Score with Enterprise Security 8.3+

Overview Enterprise Security 8.3 introduces a powerful new feature called “Entity Risk Scoring” (ERS) for ...