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
Got questions? Get answers!

Join the Splunk Community Slack to learn, troubleshoot, and make connections with fellow Splunk practitioners in real time!

Meet up IRL or virtually!

Join Splunk User Groups to connect and learn in-person by region or remotely by topic or industry.

Get Updates on the Splunk Community!

Observability Simplified: Combining User Experience, Application Performance & ...

Tech Talk Observability Simplified: Combining User Experience, Application Performance & Network ...

Event Series May & June: From Network Visibility to Service Intelligence

Unifying the Network: Moving from Alert Noise to Service Intelligence with Splunk ITSI In today’s hybrid ...

Global Splunk User Group Events: May + June 2026

Your Splunk Community Awaits: Discover Upcoming User Group Events Worldwide    Staying ahead in the fast-paced ...