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!

.conf25 Community Recap

Hello Splunkers, And just like that, .conf25 is in the books! What an incredible few days — full of learning, ...

Splunk App Developers | .conf25 Recap & What’s Next

If you stopped by the Builder Bar at .conf25 this year, thank you! The retro tech beer garden vibes were ...

Congratulations to the 2025-2026 SplunkTrust!

Hello, Splunk Community! We are beyond thrilled to announce our newest group of SplunkTrust members!  The ...