# I can't format the a timestamp from my database

**URL:** <https://discourse.nodered.org/t/i-cant-format-the-a-timestamp-from-my-database/53925>\
**Category:** Dashboard\
**Tags:** database\
**Created:** [18 November 2021 09:05 UTC](https://discourse.nodered.org/t/i-cant-format-the-a-timestamp-from-my-database/53925 "2021-11-18T09:05:43Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![evanic14](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/evanic14/32/23480_2.png) [@evanic14](https://discourse.nodered.org/u/evanic14)\
**Post date:** [18 November 2021 09:05 UTC](https://discourse.nodered.org/t/i-cant-format-the-a-timestamp-from-my-database/53925/1 "2021-11-18T09:05:43Z")

</div>

Hi, I want to get a timestamp from my database but it doesn't format it properly. this is the data i get from the database:

 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/e/7/e7ccb348bca31b5123d21529af7bb9f3bef80c5a.png)

This is how it is displayed in the dashboard:  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/2/a/2ab0384ffdf7df14c3148df39e56503f6148578b.png)

i want to see the date: DD-MM-YYYY and the time: HH:MM.SS

here's a snippet of my flow: `[{"id":"ee612edc.e2d27","type":"MSSQL","z":"455ed50a.5deadc","mssqlCN":"df8c0b88.91b0a8","name":"","query":"","outField":"payload","x":500,"y":1220,"wires":[["e984e445.265dc8","3eb0300f.3a5e2","13463601.ac0d1a","2da9a626.9638da","de547430.5c4388"]]},{"id":"b136ebf8.522798","type":"function","z":"455ed50a.5deadc","name":"Query","func":"pld = \"SELECT id,machine,persoon,status,overtime,materiaal,batch,bekken,messen,draad,timestamp FROM [Dev].[dbo].[algemeen] ORDER BY id DESC\"\nmsg.payload = pld;\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":1220,"wires":[["ee612edc.e2d27"]]},{"id":"2d93572.42fe8a8","type":"link in","z":"455ed50a.5deadc","name":"","links":["391aeafb.964266","6276249c.0e354c","6ff6730b.f01cec","88302b1a.d43c48","a7fe4dfb.f5e16","c2912be6.ac4308","ca8e0433.8e5d78","d23c5d18.1769d"],"x":55,"y":1220,"wires":[["12601ffa.9e06f"]]},{"id":"e984e445.265dc8","type":"ui_text","z":"455ed50a.5deadc","group":"20527feb.4aa22","order":1,"width":0,"height":0,"name":"status","label":"status:","format":"{{msg.payload[0].status}}","layout":"row-left","className":"","x":630,"y":1220,"wires":[]},{"id":"3eb0300f.3a5e2","type":"ui_text","z":"455ed50a.5deadc","group":"20527feb.4aa22","order":2,"width":0,"height":0,"name":"overtime","label":"tijdklok:","format":"{{msg.payload[0].overtime}}","layout":"row-left","className":"","x":640,"y":1260,"wires":[]},{"id":"2da9a626.9638da","type":"ui_text","z":"455ed50a.5deadc","group":"20527feb.4aa22","order":4,"width":0,"height":0,"name":"timestamp","label":"tijd:","format":"{{msg.payload[0].timestamp}}","layout":"row-left","className":"","x":650,"y":1340,"wires":[]},{"id":"13463601.ac0d1a","type":"ui_text","z":"455ed50a.5deadc","group":"20527feb.4aa22","order":3,"width":0,"height":0,"name":"foutcode","label":"foutcode:","format":"{{msg.payload[0].materiaal}} {{msg.payload[0].batch}} {{msg.payload[0].bekken}} {{msg.payload[0].messen}} {{msg.payload[0].draad}}","layout":"row-left","className":"","x":640,"y":1300,"wires":[]},{"id":"58c9d3ca.e23fbc","type":"ui_button","z":"455ed50a.5deadc","name":"delete","group":"20527feb.4aa22","order":7,"width":"3","height":1,"passthru":true,"label":"verwijderen","tooltip":"","color":"","bgcolor":"red","className":"","icon":"","payload":"true","payloadType":"bool","topic":"Topic","topicType":"msg","x":150,"y":1300,"wires":[["25365bd7.14f0c4","d23c5d18.1769d"]]},{"id":"96e2fcb9.9c4d1","type":"MSSQL","z":"455ed50a.5deadc","mssqlCN":"df8c0b88.91b0a8","name":"","query":"","outField":"payload","x":500,"y":1300,"wires":[[]]},{"id":"25365bd7.14f0c4","type":"function","z":"455ed50a.5deadc","name":"Query","func":"pld = \" DELETE TOP (1) FROM [Dev].[dbo].[algemeen]\"\nmsg.payload = pld;\nreturn msg; ","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":330,"y":1300,"wires":[["96e2fcb9.9c4d1"]]},{"id":"12601ffa.9e06f","type":"delay","z":"455ed50a.5deadc","name":"","pauseType":"delay","timeout":"0.5","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":170,"y":1220,"wires":[["b136ebf8.522798","ae57dc15.f239b"]]},{"id":"ae57dc15.f239b","type":"delay","z":"455ed50a.5deadc","name":"","pauseType":"delay","timeout":"30","timeoutUnits":"seconds","rate":"1","nbRateUnits":"1","rateUnits":"second","randomFirst":"1","randomLast":"5","randomUnits":"seconds","drop":false,"x":160,"y":1260,"wires":[["12601ffa.9e06f"]]},{"id":"d23c5d18.1769d","type":"link out","z":"455ed50a.5deadc","name":"select","links":["2d93572.42fe8a8"],"x":330,"y":1340,"wires":[],"l":true},{"id":"de547430.5c4388","type":"debug","z":"455ed50a.5deadc","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":500,"y":1260,"wires":[]},{"id":"df8c0b88.91b0a8","type":"MSSQL-CN","name":"Dev","server":"DESKTOP-NJL524L\\EXAMEN_TEST","encyption":false,"database":"Dev"},{"id":"20527feb.4aa22","type":"ui_group","name":"Laatste foutcode","tab":"4ac8d4a5.3b285c","order":4,"disp":true,"width":"7","collapse":false,"className":""},{"id":"4ac8d4a5.3b285c","type":"ui_tab","name":"Controle","icon":"report","order":1,"disabled":false,"hidden":false}]`

---

<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:** [18 November 2021 09:23 UTC](https://discourse.nodered.org/t/i-cant-format-the-a-timestamp-from-my-database/53925/2 "2021-11-18T09:23:06Z")

</div>

Example of formating date using angular

```auto
[{"id":"d6289761.d29bb8","type":"inject","z":"b779de97.b1b46","name":"","props":[{"p":"payload"},{"p":"topic","vt":"str"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"$now()","payloadType":"jsonata","x":180,"y":1080,"wires":[["9acd8dfd.706108","628b0273.afd064"]]},{"id":"9acd8dfd.706108","type":"debug","z":"b779de97.b1b46","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":600,"y":1080,"wires":[]},{"id":"628b0273.afd064","type":"ui_text","z":"b779de97.b1b46","group":"8b5cde76.edd58","order":14,"width":0,"height":0,"name":"","label":"text","format":"{{msg.payload | date : 'dd-MM-yyyy HH:mm:ss' }}","layout":"row-spread","x":370,"y":1060,"wires":[]},{"id":"8b5cde76.edd58","type":"ui_group","name":"","tab":"8f03e639.85956","order":1,"disp":true,"width":"12","collapse":false},{"id":"8f03e639.85956","type":"ui_tab","name":"Home","icon":"dashboard","disabled":false,"hidden":false}]

```

```auto
{{msg.payload | date : 'dd-MM-yyyy HH:mm:ss' }}

```

---

<div class="post-metadata">

**Author:** ![evanic14](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/evanic14/32/23480_2.png) [@evanic14](https://discourse.nodered.org/u/evanic14)\
**Post date:** [18 November 2021 09:37 UTC](https://discourse.nodered.org/t/i-cant-format-the-a-timestamp-from-my-database/53925/4 "2021-11-18T09:37:01Z")

</div>

oh wow that worked!  
 ![image](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/0/9/09cf339f0bbd922f931641cd80791bf9bf170b2a.png)  
thanks!

---

<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:** [2 December 2021 09:37 UTC](https://discourse.nodered.org/t/i-cant-format-the-a-timestamp-from-my-database/53925/5 "2021-12-02T09:37:43Z")

</div>

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