Getting Data In

How to convert a date field from YYYY-MM-DD to MM-DD-YYYY?

dbcase
Motivator

Hi,

I have a field in a CSV file called CREATION_DATE and currently the value in the field is (example: 2015-4-5.4.19. 50. 526000000)

I'm looking to convert it to MM/DD/YYYY (don't really need the Hour, minute, seconds)

I've tried things like

strftime(strptime(CREATION_DATE,"%Y-%m-%d. %H.%M.%S %p"),"%m-%d-%Y")
strftime(CREATION_DATE,"%m %d %Y")

and others with no luck. I'm pretty new at Splunk so I'm struggling a bit 🙂

Any thoughts?

0 Karma

ddrillic
Ultra Champion

The followings seems to be fine -

| eval CREATION_DATE="2015-4-5.19 .50"
| eval xxxx=strptime(CREATION_DATE,"%Y-%m-%d.%H .%M")

Not sure about 526000000...

ddrillic
Ultra Champion

ok, a bit better -

| eval CREATION_DATE="2015-4-5.19 .50 .526000000"
| eval xxxx=strptime(CREATION_DATE,"%Y-%m-%d.%H .%M .%Q")
0 Karma
Get Updates on the Splunk Community!

Splunk Observability for AI

Don’t miss out on an exciting Tech Talk on Splunk Observability for AI! Discover how Splunk’s agentic AI ...

[Puzzles] Solve, Learn, Repeat: Dereferencing XML to Fixed-length events

This challenge was first posted on Slack #puzzles channelFor a previous puzzle, I needed a set of fixed-length ...

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

What are Community Office Hours? Community Office Hours is an interactive 60-minute Zoom series where ...