Splunk Search

Adding and defining the value for a new Search Field.

Substance82
Path Finder

How do I add a  new field and set the value to seven days ago from the current date, snapped to the
beginning of the current date? I know the date syntax should be "earliest=-7d@d", but am unsure if I should use the eval command to add the field and the specific syntax. Thanks. 

Labels (2)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

eval is the command to use to add a new field to an event.  Use the relative_time function to help set the value.

| eval newField = relative_time(now(), "-7d@d")

 

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

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

eval is the command to use to add a new field to an event.  Use the relative_time function to help set the value.

| eval newField = relative_time(now(), "-7d@d")

 

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

Substance82
Path Finder

Thanks a million!

0 Karma
Get Updates on the Splunk Community!

See just what you’ve been missing | Observability tracks at Splunk University

Looking to sharpen your observability skills so you can better understand how to collect and analyze data from ...

Weezer at .conf25? Say it ain’t so!

Hello Splunkers, The countdown to .conf25 is on-and we've just turned up the volume! We're thrilled to ...

How SC4S Makes Suricata Logs Ingestion Simple

Network security monitoring has become increasingly critical for organizations of all sizes. Splunk has ...