# Wrong data with form node

**URL:** <https://discourse.nodered.org/t/wrong-data-with-form-node/61795>\
**Category:** General\
**Created:** [26 April 2022 10:42 UTC](https://discourse.nodered.org/t/wrong-data-with-form-node/61795 "2022-04-26T10:42:19Z")\
**Posts on this page:** 8\
**Page:** 1

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [26 April 2022 10:42 UTC](https://discourse.nodered.org/t/wrong-data-with-form-node/61795/1 "2022-04-26T10:42:20Z")

</div>

I have a form node to insert a Date and other two string data.  
The problem is that an incorrect data is saved on my SQL database and shown on a table in the UI.

This is the flow (part of a complex flow):

```auto
[{"id":"5a6581d01a879e1c","type":"ui_form","z":"2380dbebb998c1d1","name":"","label":"","group":"2406fc0b6515765c","order":2,"width":6,"height":1,"options":[{"label":"DATA ULTIMO CONTROLLO","value":"DATAULTIMOCONTROLLO","type":"date","required":true,"rows":null},{"label":"RESPONSABILE","value":"RESPONSABILE","type":"text","required":true,"rows":null},{"label":"NOTE","value":"NOTE","type":"text","required":false,"rows":null}],"formValue":{"DATAULTIMOCONTROLLO":"","RESPONSABILE":"","NOTE":""},"payload":"","submit":"INVIA","cancel":"CANCEL","topic":"topic2","topicType":"str","splitLayout":"","className":"","x":630,"y":1020,"wires":[["73dfefc9e70f4fcf","cda5ffc0469aaf2b"]]},{"id":"a4ac4493082bb7f8","type":"MSSQL","z":"2380dbebb998c1d1","mssqlCN":"6fb70e68d89e36c4","name":"","outField":"payload","returnType":"0","throwErrors":"0","query":"INSERT INTO [DB_Strumentazione].[dbo].[SCADENZIARIO]\n(ID_STRUM,DATAULTIMOCONTROLLO,RESPONSABILE,NOTE) \nVALUES (@ID_STRUM, @DATAULTIMOCONTROLLO,@RESPONSABILE,@NOTE)","modeOpt":"","modeOptType":"query","queryOpt":"","queryOptType":"editor","paramsOpt":"","paramsOptType":"editor","rows":"","rowsType":"msg","params":[{"output":false,"name":"DATAULTIMOCONTROLLO","type":"VarChar","valueType":"msg","value":"payload.topic2.DATAULTIMOCONTROLLO","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}},{"output":false,"name":"RESPONSABILE","type":"VarChar","valueType":"msg","value":"payload.topic2.RESPONSABILE","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}},{"output":false,"name":"NOTE","type":"VarChar","valueType":"msg","value":"payload.topic2.NOTE","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}},{"output":false,"name":"ID_STRUM","type":"int","valueType":"msg","value":"payload.topic1[0].ID","options":{"nullable":true,"primary":false,"identity":false,"readOnly":false}}],"x":1040,"y":1080,"wires":[[]]},{"id":"73dfefc9e70f4fcf","type":"debug","z":"2380dbebb998c1d1","name":"Form Out","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"payload","targetType":"msg","statusVal":"","statusType":"auto","x":880,"y":1180,"wires":[]},{"id":"cda5ffc0469aaf2b","type":"join","z":"2380dbebb998c1d1","name":"","mode":"custom","build":"object","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"2","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":810,"y":1020,"wires":[["a4ac4493082bb7f8","749be14a50ba83e5","227b492266f8cb1c"]]},{"id":"2406fc0b6515765c","type":"ui_group","name":"Inserimento data controllo","tab":"21286fd2ee7bdc0c","order":7,"disp":true,"width":"10","collapse":false,"className":""},{"id":"6fb70e68d89e36c4","type":"MSSQL-CN","name":"DB_Strumentazione","server":"GIOVANNAQ\\SQLEXPRESS","port":"","encyption":true,"trustServerCertificate":true,"database":"DB_Strumentazione","useUTC":true,"connectTimeout":"","requestTimeout":"","cancelTimeout":"","pool":"","parseJSON":false,"enableArithAbort":true},{"id":"21286fd2ee7bdc0c","type":"ui_tab","name":"Inserimento Date Controllo","icon":"assignment","order":5,"disabled":false,"hidden":true}]

```

The output of the form node is joined with another output.

I have seen other post, but I didn't find a function which solved my problem.

Is there a way to add +1 (day) when I insert Date on the SQL table?

Thanks for your help

---

<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:** [26 April 2022 11:56 UTC](https://discourse.nodered.org/t/wrong-data-with-form-node/61795/2 "2022-04-26T11:56:15Z")

</div>

There is not enough information to help you.

> [@QGIO](#):
>
> The problem is that an incorrect data is saved on my SQL database

What data? How is it incorrect?

> [@QGIO](#):
>
> shown on a table in the UI.

Screenshot? what should it be?

> [@QGIO](#):
>
> The output of the form node is joined with another output.

What output?

> [@QGIO](#):
>
> I have seen other post

What post?

> [@QGIO](#):
>
> but I didn't find a function which solved my problem

What is the problem?

> [@QGIO](#):
>
> Is there a way to add +1 (day) when I insert Date on the SQL table

Yes, use the `DATEADD` SQL function

---

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [26 April 2022 12:02 UTC](https://discourse.nodered.org/t/wrong-data-with-form-node/61795/3 "2022-04-26T12:02:27Z")

</div>

Incorrect Date (not data).  
I insert 26/04/2022 in the form node, and 2022-04-25T00:00:00.000Z is saved.

I would like to add 1 day in the SQL node where I put the input DATAULTIMOCONTROLLO. Is it possible?

---

<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:** [26 April 2022 12:10 UTC](https://discourse.nodered.org/t/wrong-data-with-form-node/61795/4 "2022-04-26T12:10:25Z")

</div>

I see you have set the field type of `DATAULTIMOCONTROLLO` to `varchar`  
I assume since you called it DATAULTIMOCONTROLLO ("data ultimo controllo" ~ " last check date") you simply want to store the DATE (not a full datetime / not a timestamp)?

Try using the [`date`](https://docs.microsoft.com/en-us/sql/t-sql/data-types/date-transact-sql?view=sql-server-ver15) type.

Also, before sending `payload.topic2.DATAULTIMOCONTROLLO` you could use a function or MOMENT or JSONata to convert the URC timestamp to a local YYYY/DD/MM string.

There are lots of threads on the forum that demonstrate converting a JS Date to a local / locale time.

---

<div class="post-metadata">

**Author:** ![TotallyInformation](https://sea2.discourse-cdn.com/flex026/user_avatar/discourse.nodered.org/totallyinformation/32/31_2.png) [@TotallyInformation](https://discourse.nodered.org/u/TotallyInformation)\
**Post date:** [26 April 2022 12:12 UTC](https://discourse.nodered.org/t/wrong-data-with-form-node/61795/5 "2022-04-26T12:12:47Z")

</div>

> [@Steve-Mcl](#):
>
> There are lots of threads on the forum that demonstrate converting a JS Date to a local / locale time.

And just as many that tell you not to store dates/times as local! Store as UTC if you want to avoid future DST/TZ issues.

---

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [26 April 2022 12:17 UTC](https://discourse.nodered.org/t/wrong-data-with-form-node/61795/6 "2022-04-26T12:17:43Z")

</div>

Do you mean here?

 ![immagine](https://us1.discourse-cdn.com/flex026/uploads/nodered/original/3X/d/f/df9594fc5669954e6e21d2cc9315fe98a5f05dd6.png)

---

<div class="post-metadata">

**Author:** ![QGIO](https://avatars.discourse-cdn.com/v4/letter/q/f17d59/32.png) [@QGIO](https://discourse.nodered.org/u/QGIO)\
**Post date:** [26 April 2022 12:57 UTC](https://discourse.nodered.org/t/wrong-data-with-form-node/61795/7 "2022-04-26T12:57:45Z")

</div>

> [@Steve-Mcl](#):
>
> `payload.topic2.DATAULTIMOCONTROLLO`

Solved by using MOMENT node

---

<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:** [10 May 2022 12:58 UTC](https://discourse.nodered.org/t/wrong-data-with-form-node/61795/8 "2022-05-10T12:58:39Z")

</div>

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