Getting Data In

Want to replace column name with today's date

sabari80
Explorer

I have a query to display following 3 fields 

| table pp_user_action_name,Today_Calls,Avg_today

i want to replace 'Avg_today' column header with today's date like '11/1/2023' 

is it possible? 

Labels (1)
0 Karma
1 Solution

richgalloway
SplunkTrust
SplunkTrust

Here's one method.  There may be others.

| makeresults 
| eval pp_user_action_name="foo",Today_Calls=42,Avg_today=3 
| table pp_user_action_name,Today_Calls,Avg_today
| rename Avg_today as 
    [| makeresults 
    ``` Get today's date and format it ```
    | eval today=strftime(now(), "%m/%d/%Y") 
    ``` Return only the value of the today field ```
    | return $today]
---
If this reply helps you, Karma would be appreciated.

View solution in original post

richgalloway
SplunkTrust
SplunkTrust

Here's one method.  There may be others.

| makeresults 
| eval pp_user_action_name="foo",Today_Calls=42,Avg_today=3 
| table pp_user_action_name,Today_Calls,Avg_today
| rename Avg_today as 
    [| makeresults 
    ``` Get today's date and format it ```
    | eval today=strftime(now(), "%m/%d/%Y") 
    ``` Return only the value of the today field ```
    | return $today]
---
If this reply helps you, Karma would be appreciated.

sabari80
Explorer

its working. can we append any string with this date? For Ex: 11/1/2023_Response

0 Karma

richgalloway
SplunkTrust
SplunkTrust

Sure!  Just use the concatenation operator (.) in the eval command.

| eval today=strftime(now(), "%m/%d/%Y") . "_Response"
---
If this reply helps you, Karma would be appreciated.
0 Karma

sabari80
Explorer

Thanks. i am all set. 

0 Karma
Get Updates on the Splunk Community!

Introducing the Splunk Community Dashboard Challenge!

Welcome to Splunk Community Dashboard Challenge! This is your chance to showcase your skills in creating ...

Built-in Service Level Objectives Management to Bridge the Gap Between Service & ...

Wednesday, May 29, 2024  |  11AM PST / 2PM ESTRegister now and join us to learn more about how you can ...

Get Your Exclusive Splunk Certified Cybersecurity Defense Engineer Certification at ...

We’re excited to announce a new Splunk certification exam being released at .conf24! If you’re headed to Vegas ...