# Template node changing format of datetime stamp

**URL:** <https://discourse.nodered.org/t/template-node-changing-format-of-datetime-stamp/90947>\
**Category:** General\
**Created:** [13 September 2024 13:23 UTC](https://discourse.nodered.org/t/template-node-changing-format-of-datetime-stamp/90947 "2024-09-13T13:23:12Z")\
**Posts on this page:** 5\
**Page:** 1

<div class="post-metadata">

**Author:** ![hobbes1069](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hobbes1069/32/39892_2.png) [@hobbes1069](https://discourse.nodered.org/u/hobbes1069)\
**Post date:** [13 September 2024 13:23 UTC](https://discourse.nodered.org/t/template-node-changing-format-of-datetime-stamp/90947/1 "2024-09-13T13:23:12Z")

</div>

I've got a flow that queries an Oracle DB and returns a datetime stamp, I'm then formatting it using a template node for ingestion into a Tulip Table node.

For some reason the template node is deciding that it should change the format of the stamp:

Input:

```auto
msg.completeDate: "2021-04-24T04:00:00.000Z"

```

Template node contents:

```auto
{
    "sfhqp_date_completed": "{{completeDate}}"
}

```

Output from the template node:

```auto
sfhqp_date_completed: "Sat Apr 24 2021 00:00:00 GMT-0400 (Eastern Daylight Time)"

```

Why is the template node changing the timestamp format?

I can't share too much for company reasons but if needed I can create a minimal reproducer in a separate flow but hopefully that's not needed.

---

<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:** [13 September 2024 13:51 UTC](https://discourse.nodered.org/t/template-node-changing-format-of-datetime-stamp/90947/2 "2024-09-13T13:51:31Z")

</div>

The Oracle DB is returning a [Date object](https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Global_Objects/Date). you will need to convert it with either JS in a function node  
`msg.sfhqp_date_completed = msg.completeDate.toISOString();`  
No template required then

Or ask Oracle to format it to an ISO timestamp [Format Models](https://docs.oracle.com/en/database/oracle/oracle-database/19/sqlrf/Format-Models.html#GUID-49B32A81-0904-433E-B7FE-51606672183A)

---

<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:** [13 September 2024 14:09 UTC](https://discourse.nodered.org/t/template-node-changing-format-of-datetime-stamp/90947/3 "2024-09-13T14:09:00Z")

</div>

The reason that it comes out as it does in the template node is that the template node, seeing that it is not a string, calls `toString()` to convert it, which gives the string you see.

---

<div class="post-metadata">

**Author:** ![hobbes1069](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/hobbes1069/32/39892_2.png) [@hobbes1069](https://discourse.nodered.org/u/hobbes1069)\
**Post date:** [13 September 2024 14:10 UTC](https://discourse.nodered.org/t/template-node-changing-format-of-datetime-stamp/90947/4 "2024-09-13T14:10:05Z")

</div>

Thanks guys, I had to modify it slightly, but @E1cid suggestion worked.

---

<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:** [27 September 2024 14:10 UTC](https://discourse.nodered.org/t/template-node-changing-format-of-datetime-stamp/90947/5 "2024-09-27T14:10:19Z")

</div>

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