Answers.Body: <p>Agree with Coleman that it would be great to have Format Date in SearchDisplays.</p>
  <p>If you want to do this in the Smarty rewrite, you can do something like <code>{&quot;[start_date]&quot;|date_format:&quot;%H:%M&quot;}</code>, without the field transformation.</p>
  
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-24T05:41:19.917Z
Answers.Text: I made a small adjustment to match the actual field name: `{"[TIME_start_date]"|date_format:"%H:%M"}`  and that worked like a charm! <3 Thank you Lars! I can see this code is syntactically a little different from my previous, failed attempts. I was close though :-) Gotta learn more about how Smarty is written inside SearchKit now.
Answers.UserDisplayName: Torben Gundtofte-Bruun
Answers.ContentLicense: CC BY-SA 4.0
Answers.CreationDate: 2023-10-22T16:25:45.300Z
Answers.LastActivityDate: 2023-10-22T16:25:45.300Z
Answers.UserDisplayName: Lars SG
Body: <p>How to get substring of a SearchKit result column? I want to truncate the event start time from <code>17:15:00</code> to just <code>17:15</code>.</p>
  <p><strong>What I have:</strong></p>
  <ul>
  <li>My test setup is newest WP 6.3.2 and newest CiviCRM 5.66.0.</li>
  <li>CiviEvent: several events, with a starting date and time, e.g. <code>17:15</code>.</li>
  <li>SearchKit: a search that gives me open events in the next 2 weeks.<br />
  The result presents no actions, no sorting, just a static table listing.</li>
  <li>Form Builder: a form to hold the results from the search.</li>
  <li>WordPress: a page that contains the shortcode with my search.</li>
  </ul>
  <p><strong>What I want:</strong></p>
  <ul>
  <li>The final output contains a column with <em>event start time including seconds</em>. It is silly to show an event start time with seconds - and I understand that this comes from the timestamp format in the database.</li>
  <li>I do not see any suitable field transformation that I could apply in the SearchKit.</li>
  <li>In the reports output part of SearchKit, each column has the <code>Rewrite Text</code> function using &quot;SMARTY conditions&quot; but it is not clear to me how that works. My latest attempt is <code>[{TIME_start_date|substr:0:5}]</code> but that generates no output. <strong>Can you give an example?</strong></li>
  <li>I cannot think of another way to truncate the time value, or any way to do any kind of substring operation at all.</li>
  </ul>
  <p>How can I get rid of the seconds in the time column?</p>
  <p><a href="https://i.sstatic.net/5XlvR.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/5XlvR.png" alt="event listing" /></a></p>
  <p><a href="https://i.sstatic.net/wTiRM.png" rel="nofollow noreferrer"><img src="https://i.sstatic.net/wTiRM.png" alt="field transformations" /></a></p>
  <p>(ignore the missing localisation of the weekday and month words)</p>
  
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-10-22T11:15:23.387Z
Comments.Text: I think SearchKit is sorely missing a "Format Date" column setting. Do you think you could sponsor that feature?
Comments.UserDisplayName: Coleman
Comments.ContentLicense: CC BY-SA 4.0
Comments.CreationDate: 2023-10-24T05:36:37.447Z
Comments.Text: Depends on what you mean by the word "sponsor", @Coleman? I sadly cannot provide funding, and my PHP skills are not up to snuff ... but I might be able to contribute in other ways.
Comments.UserDisplayName: Torben Gundtofte-Bruun
Tags: <civievent><searchkit>
Title: How to get substring of a SearchKit result column?
ThreadText: # How to get substring of a SearchKit result column?
  
  (Asked by: username_0 on 2023-10-22)
  
  How to get substring of a SearchKit result column? I want to truncate the event start time from `17:15:00` to just `17:15`.
  
  **What I have:**
  
  * My test setup is newest WP 6.3.2 and newest CiviCRM 5.66.0.
  * CiviEvent: several events, with a starting date and time, e.g. `17:15`.
  * SearchKit: a search that gives me open events in the next 2 weeks.  
    The result presents no actions, no sorting, just a static table listing.
  * Form Builder: a form to hold the results from the search.
  * WordPress: a page that contains the shortcode with my search.
  
  **What I want:**
  
  * The final output contains a column with *event start time including seconds*. It is silly to show an event start time with seconds - and I understand that this comes from the timestamp format in the database.
  * I do not see any suitable field transformation that I could apply in the SearchKit.
  * In the reports output part of SearchKit, each column has the `Rewrite Text` function using "SMARTY conditions" but it is not clear to me how that works. My latest attempt is `[{TIME_start_date|substr:0:5}]` but that generates no output. **Can you give an example?**
  * I cannot think of another way to truncate the time value, or any way to do any kind of substring operation at all.
  
  How can I get rid of the seconds in the time column?
  
  [![event listing](https://i.sstatic.net/5XlvR.png)](https://i.sstatic.net/5XlvR.png)
  
  [![field transformations](https://i.sstatic.net/wTiRM.png)](https://i.sstatic.net/wTiRM.png)
  
  (ignore the missing localisation of the weekday and month words)
  
  **Tags:** civievent, searchkit
  
  > **Comments:**
  > **username_1**: I think SearchKit is sorely missing a "Format Date" column setting. Do you think you could sponsor that feature?  
  > **username_0**: Depends on what you mean by the word "sponsor", @username_1? I sadly cannot provide funding, and my PHP skills are not up to snuff ... but I might be able to contribute in other ways.  
  
  ---
  
  ## 1 answers
  
  ### Answer by username_2 on 2023-10-22. Score: 3 | Accepted answer
  
  Agree with username_1 that it would be great to have Format Date in SearchDisplays.
  
  If you want to do this in the Smarty rewrite, you can do something like `{"[start_date]"|date_format:"%H:%M"}`, without the field transformation.
  
  > **Comments:**
  > **username_0**: I made a small adjustment to match the actual field name: `{"[TIME_start_date]"|date_format:"%H:%M"}`  and that worked like a charm! <3 Thank you username_2! I can see this code is syntactically a little different from my previous, failed attempts. I was close though :-) Gotta learn more about how Smarty is written inside SearchKit now.  
  
  ---
  
  