Dashboards & Visualizations

How to fetch time in Date format?

aditsss
Motivator

Hi All,

I have one requirement .

I have one lookup in which there are two columns:

RunDateTime and Closed Time

RunDateTime -  2021-09-21 03:58:07

CLosedTime - 2019-01-08T14:50:36.000+0000

I need both RunDateTime and closedTime in below format:

RunDateTime- 2021-09-21

ClosedTime- 2019-01-08

query:

|inputlookup SDC.csv| table RunDateTime  ClosedTime

 

Labels (2)
Tags (1)
0 Karma

bowesmana
SplunkTrust
SplunkTrust

@aditsss 

Very simply, you can do

| inputlookup SDC.csv
| eval RunDateTime=substr(RunDateTime,1,10), ClosedTime=substr(ClosedTime,1,10)
| table RunDateTime  ClosedTime

which is just taking the first 10 characters of the string, as long as your data is well structures, i.e. leading zeros are used in days and months. 

0 Karma

aditsss
Motivator

@bowesmana 

It was working for me previously . But I added one more column at the end of my lookup and after that I am getting rundatetime in the below Format.

Can you guide me on that:

rundatetime

12/30/2020
12/24/2020
12/2/2020
11/18/2020
11/17/2020
11/14/2020
10/27/2020
10/25/2020
10/20/2020
10/17/2020
10/16/2020
1/9/2021 3
1/8/2021 3

 

I want it in proper Date format. Can you guide me on that.

0 Karma

bowesmana
SplunkTrust
SplunkTrust

@aditsss 

| eval rundatetime=strftime(strptime(rundatetime,"%m/%d/%Y"), "%F")

 

 

0 Karma
Career Survey
First 500 qualified respondents will receive a $20 gift card! Tell us about your professional Splunk journey.
Get Updates on the Splunk Community!

Thanks for the Memories! Splunk University, .conf25, and our Community

Thank you to everyone in the Splunk Community who joined us for .conf25, which kicked off with our iconic ...

Data Persistence in the OpenTelemetry Collector

This blog post is part of an ongoing series on OpenTelemetry. What happens if the OpenTelemetry collector ...

Introducing Splunk 10.0: Smarter, Faster, and More Powerful Than Ever

Now On Demand Whether you're managing complex deployments or looking to future-proof your data ...