Splunk Search

How to calculate dates in my search?

ositaumeozulu
Explorer

Sorry team to bother you again, i have a code that is giving me issues

| eval InT = (strptime('LastPickupDate',"%m-%d-%Y %H:%M:%S")) + (('DaysOfARVRefil'+ 28)*86400)

| stats list(InT) by FacilityName

but the column InT is all blank, again how do i convert InT back to readable date and list them by facility names 

many thanks

osita

Labels (1)
Tags (1)
0 Karma
1 Solution

gcusello
SplunkTrust
SplunkTrust

Hi @ositaumeozulu,

to have the InT date you could also use reletive_time() function (https://docs.splunk.com/Documentation/SCS/current/SearchReference/DateandTimeFunctions), nd anyway, you have to convert the epochtime of your calculation in Human Readable format.

something like this:

| eval InT = strftime(relative_time(strptime('LastPickupDate',"%m-%d-%Y %H:%M:%S"),"+28d"),"%m-%d-%Y %H:%M:%S")

Ciao.

Giuseppe

 

View solution in original post

gcusello
SplunkTrust
SplunkTrust

Hi @ositaumeozulu,

to have the InT date you could also use reletive_time() function (https://docs.splunk.com/Documentation/SCS/current/SearchReference/DateandTimeFunctions), nd anyway, you have to convert the epochtime of your calculation in Human Readable format.

something like this:

| eval InT = strftime(relative_time(strptime('LastPickupDate',"%m-%d-%Y %H:%M:%S"),"+28d"),"%m-%d-%Y %H:%M:%S")

Ciao.

Giuseppe

 

ositaumeozulu
Explorer

@gcusello code not working, i keep getting blanks , i want to add days to a date and get my answer in date format

0 Karma
Get Updates on the Splunk Community!

Prove Your Splunk Prowess at .conf25—No Prereqs Required!

Your Next Big Security Credential: No Prerequisites Needed We know you’ve got the skills, and now, earning the ...

Splunk Observability Cloud's AI Assistant in Action Series: Observability as Code

This is the sixth post in the Splunk Observability Cloud’s AI Assistant in Action series that digs into how to ...

Splunk Answers Content Calendar, July Edition I

Hello Community! Welcome to another month of Community Content Calendar series! For the month of July, we will ...