# Datetime formatting issue

**URL:** https://discourse.nodered.org/t/datetime-formatting-issue/99169
**Category:** General
**Created:** [26 September 2025 11:18 UTC](https://discourse.nodered.org/t/datetime-formatting-issue/99169 "2025-09-26T11:18:34Z")
**Posts on this page:** 7
**Page:** 1

<div class="post-metadata">

### Author: ![azan5050](https://avatars.discourse-cdn.com/v4/letter/a/bc79bd/32.png) [@azan5050](https://discourse.nodered.org/u/azan5050)
#### Post date: [26 September 2025 11:18 UTC](https://discourse.nodered.org/t/datetime-formatting-issue/99169/1 "2025-09-26T11:18:34Z")

</div>

Create a dashboard with two datetime inputs. Convert these UTC times to the server's local time and format them for SQL Server's `smalldatetime` type. Then, query the database for records within that range and send the results to a chart.

26/09/2025, 16:22:54node: debug 15  
sensor\_data\_query : msg.payload : Object  
object  
query: string

```
        SELECT [Id], [SensorName], [SensorValue], [Alert], [Timestamp]
        FROM [IndustrialDB].[dbo].[SensorData]
        WHERE [Timestamp] BETWEEN ? AND ?
        ORDER BY [Timestamp] ASC

```

params: array[2]  
0: "2025-09-25 10:58:00"  
1: "2025-09-26 11:03:00"

 ![Screenshot 2025-09-26 162021](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/5/a/5a3d7d63da371370f53ca1d7c0d34b3d41b4b453.png)  
 ![Screenshot 2025-09-26 162154](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/3/0322bc813b6f333682f8c9893e2550c753ef50a4.png)

---

<div class="post-metadata">

### Author: ![jbudd](https://avatars.discourse-cdn.com/v4/letter/j/5f8ce5/32.png) [@jbudd](https://discourse.nodered.org/u/jbudd)
#### Post date: [26 September 2025 13:33 UTC](https://discourse.nodered.org/t/datetime-formatting-issue/99169/2 "2025-09-26T13:33:05Z")

</div>

Welcome to the foum @azan5050

> [@azan5050](#):
>
> Create a dashboard with two datetime inputs. Convert these UTC times to the server's local time and format them for SQL Server's `smalldatetime` type. Then, query the database for records within that range and send the results to a chart.

Are these your instructions to people trying to reply in the forum, or your boss's instructions to you?

---

<div class="post-metadata">

### Author: ![azan5050](https://avatars.discourse-cdn.com/v4/letter/a/bc79bd/32.png) [@azan5050](https://discourse.nodered.org/u/azan5050)
#### Post date: [29 September 2025 05:14 UTC](https://discourse.nodered.org/t/datetime-formatting-issue/99169/3 "2025-09-29T05:14:20Z")

</div>

my boss instruction to me

---

<div class="post-metadata">

### Author: ![Colin](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/colin/32/17040_2.png) [@Colin](https://discourse.nodered.org/u/Colin)
#### Post date: [29 September 2025 08:38 UTC](https://discourse.nodered.org/t/datetime-formatting-issue/99169/4 "2025-09-29T08:38:39Z")

</div>

Are you asking for help? If so what is the question?

---

<div class="post-metadata">

### Author: ![E1cid](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/e1cid/32/77971_2.png) [@E1cid](https://discourse.nodered.org/u/E1cid)
#### Post date: [29 September 2025 15:22 UTC](https://discourse.nodered.org/t/datetime-formatting-issue/99169/5 "2025-09-29T15:22:05Z")

</div>

Not knowing which dashboard you are using , guess dashboard2

You can also use a form to collect all input  
example flow

 ![chrome_screenshot_29 Sep 2025 16_12_59 BST](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/7/d/7da55faf06face5c272e09beacbb0dbd5b6c89ef.png)  
look in dashboard2  
 ![chrome_screenshot_29 Sep 2025 16_13_25 BST](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/6/6/667e33bcc5e4d51eb8e493b45cc266bffeb09e1d.png)

example flow json [How to import/export a flow](https://nodered.org/docs/user-guide/editor/workspace/import-export)

```auto
[{"id":"98faa405e180b3a6","type":"ui-form","z":"d1395164b4eec73e","name":"","group":"9d83cd8b3d5ee33c","label":"","order":1,"width":0,"height":0,"options":[{"label":"date from","key":"dfrom","type":"date","required":true,"rows":null},{"label":"time from","key":"tfrom","type":"time","required":true,"rows":null},{"label":"date to","key":"dto","type":"date","required":true,"rows":null},{"label":"time to","key":"tto","type":"time","required":true,"rows":null}],"formValue":{"dfrom":"","tfrom":"","dto":"","tto":""},"payload":"","submit":"submit","cancel":"clear","resetOnSubmit":false,"topic":"topic","topicType":"msg","splitLayout":true,"className":"","passthru":false,"dropdownOptions":[],"x":710,"y":2120,"wires":[["01bedafdbd172c91"]]},{"id":"01bedafdbd172c91","type":"template","z":"d1395164b4eec73e","name":"","field":"payload","fieldType":"msg","format":"handlebars","syntax":"mustache","template":"[\n\"{{payload.dfrom}} {{payload.tfrom}}\",\n\"{{payload.dto}} {{payload.tto}}\"\n]","output":"json","x":880,"y":2120,"wires":[["f25551b1d24cfba0"]]},{"id":"f25551b1d24cfba0","type":"debug","z":"d1395164b4eec73e","name":"debug 6","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1060,"y":2120,"wires":[]},{"id":"9d83cd8b3d5ee33c","type":"ui-group","name":"Group1","page":"c694d0ebe0d2b702","width":"6","height":"1","order":1,"showTitle":true,"className":"","visible":"true","disabled":"false","groupType":"default"},{"id":"c694d0ebe0d2b702","type":"ui-page","name":"Page1","ui":"1805777f90e92057","path":"/page1","icon":"home","layout":"grid","theme":"35ee7753b5b3599b","breakpoints":[{"name":"Default","px":"0","cols":"3"},{"name":"Tablet","px":"576","cols":"6"},{"name":"Small Desktop","px":"768","cols":"9"},{"name":"Desktop","px":"1024","cols":"12"}],"order":1,"className":"","visible":"true","disabled":"false"},{"id":"1805777f90e92057","type":"ui-base","name":"dashboard ","path":"/dashboard","appIcon":"","includeClientData":true,"acceptsClientConfig":["ui-notification","ui-control"],"showPathInSidebar":false,"headerContent":"page","titleBarStyle":"default","showReconnectNotification":false,"notificationDisplayTime":"5","showDisconnectNotification":false},{"id":"35ee7753b5b3599b","type":"ui-theme","name":"Theme Name","colors":{"surface":"#16234b","primary":"#1d44b9","bgPage":"#ecf2f8","groupBg":"#ffffff","groupOutline":"#cccccc"},"sizes":{"density":"default","pagePadding":"12px","groupGap":"12px","groupBorderRadius":"4px","widgetGap":"12px"}}]

```

There are also many examples of how to format a timestamp (both unix and iso) using change node and $moment and $fromMillis using JSONATA.  
You can also use days.js and moment.js in a function node.  
There is also the moment contrib node.  
If you search the form for more info, there is plenty available.

---

<div class="post-metadata">

### Author: ![Steve-Mcl](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/steve-mcl/32/4826_2.png) [@Steve-Mcl](https://discourse.nodered.org/u/Steve-Mcl)
#### Post date: [29 September 2025 15:29 UTC](https://discourse.nodered.org/t/datetime-formatting-issue/99169/6 "2025-09-29T15:29:42Z")

</div>

> [@E1cid](#):
>
> Not knowing which dashboard you are using , guess dashboard2

The top bar colour in the screenshot screens old/depreciated node-red-dashboard (not Dasboard-2)

---

<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: [28 November 2025 15:29 UTC](https://discourse.nodered.org/t/datetime-formatting-issue/99169/7 "2025-11-28T15:29:46Z")

</div>

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