# Sort ui\_table by timestamp

**URL:** <https://discourse.nodered.org/t/sort-ui-table-by-timestamp/84041>\
**Category:** General\
**Created:** [26 December 2023 15:10 UTC](https://discourse.nodered.org/t/sort-ui-table-by-timestamp/84041 "2023-12-26T15:10:21Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![druckstick.at](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@druckstick.at](https://discourse.nodered.org/u/druckstick.at)\
**Post date:** [26 December 2023 15:10 UTC](https://discourse.nodered.org/t/sort-ui-table-by-timestamp/84041/1 "2023-12-26T15:10:21Z")

</div>

Hello everybody!  
I use a mysql database and display the data with the ui\_table.  
This all works great too.  
Since the new mysql entries are added at the bottom, ui\_table also displays the new values at the bottom.  
I would now like to have the new values displayed at the top without having to sort them manually every time.  
I would like to use the Timestamp column for this (2023-12-26T13:33:14.000Z)  
Can someone help me with that?  
thank you very much

---

<div class="post-metadata">

**Author:** ![dceejay](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/dceejay/32/38_2.png) [@dceejay](https://discourse.nodered.org/u/dceejay)\
**Post date:** [26 December 2023 18:32 UTC](https://discourse.nodered.org/t/sort-ui-table-by-timestamp/84041/2 "2023-12-26T18:32:08Z")

</div>

Can you not make your mysql request return in the order you want ?

> <https://stackoverflow.com/questions/11493463/mysql-order-timestamp-values-ascending-in-order-from-newest-to-oldest>

---

<div class="post-metadata">

**Author:** ![druckstick.at](https://avatars.discourse-cdn.com/v4/letter/d/a587f6/32.png) [@druckstick.at](https://discourse.nodered.org/u/druckstick.at)\
**Post date:** [26 December 2023 19:31 UTC](https://discourse.nodered.org/t/sort-ui-table-by-timestamp/84041/3 "2023-12-26T19:31:04Z")

</div>

Thank you!  
I thought way too complicated.  
Here is my finished function node, in case someone needs it.

```auto
msg.topic = "SELECT * FROM Table1 WHERE Column1 = '" + msg.payload.value1 + "' ORDER BY Timestamp DESC; "

return msg;

```

---

<div class="post-metadata">

**Author:** ![system](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/1X/d073cd938eafa2e558d7c2cd59003b3ef4963033.png) [@system](https://discourse.nodered.org/u/system)\
**Post date:** [9 January 2024 19:31 UTC](https://discourse.nodered.org/t/sort-ui-table-by-timestamp/84041/4 "2024-01-09T19:31:30Z")

</div>

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.
