Node Red is changing my date text

Node red is changing my date text while I am trying to modify it to format YYY-MM-DD and it is very frustration. If I use moment it subtracts a day for some reason and if it add a day; null values generate a date which make no sense.

Does anyone have any idea why this occurs?

A bit more info would be helpful... what node is that you are showing us ? It doesn't look like one of the core ones ?

I was using the node-red-contrib-string or node-red-contrib-moment nodes to try and format the date. However; even with out any nodes making changes the ui-form changes the date to be a day behind for some reason

Exactly how much difference is there between the date extracted from the database and the date displayed on ui-form? An actual example might help.

What timezone are you in?

Is the database hosted locally?

There is 1 day of difference between the database and the ui-form. Sorry
Example is below

[{"id":"9d60d084003b46ca","type":"tab","label":"Flow 5","disabled":false,"info":"","env":[]},{"id":"3483688aa2fe73f8","type":"debug","z":"9d60d084003b46ca","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1230,"y":260,"wires":[]},{"id":"6aadc2e9e55a5cee","type":"ui_table","z":"9d60d084003b46ca","group":"8220361faab44749","name":"resaults","order":1,"width":12,"height":4,"columns":[{"field":"date","title":"Date","width":"","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"rga_number","title":"RGA #","width":"","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"pump_number","title":"Pump#","width":"","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"acc_rej","title":"Acc/Rej","width":"","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}},{"field":"contaminated","title":"Contaminated","width":"","align":"left","formatter":"plaintext","formatterParams":{"target":"_blank"}}],"outputs":1,"cts":true,"x":1600,"y":300,"wires":[["03ba6377d589819b","7d21713fea51f9ed"]]},{"id":"03ba6377d589819b","type":"function","z":"9d60d084003b46ca","name":"quality_rga to form","func":"var id          =msg.payload.id\nvar rganum       = msg.payload.rga_number\nvar gw           = msg.payload.LC_GW\nvar comp         = msg.payload.company\nvar deft         = msg.payload.defects\nvar dtp          = msg.payload.days_to_process\nvar dr           = msg.payload.date_rec\nvar adp           = msg.payload.actual_days_process\nvar ar           = msg.payload.acc_rej\nvar pump         = msg.payload.pump_number\nvar cont         = msg.payload.contaminated\nvar bear         = msg.payload.bearing\nvar bvend        = msg.payload.b_vendor\nvar seal         = msg.payload.seal\nvar svend        = msg.payload.s_vendor\nvar wo           = msg.payload.work_order\nvar dou          = msg.payload.douwei_num\nvar sct          = msg.payload.sc_trace\nvar db           = msg.payload.date_built_vendor\nvar rc           = msg.payload.reason_code\nvar mil          = msg.payload.milage\nvar vin          = msg.payload.vin\nvar dol          = msg.payload.issued_refund\nvar ask          = msg.payload.asking_refund\nvar comment      = msg.payload.additional_comments\n\nlet drec = new Date(msg.payload.date)\nlet dateTimeLocal = new Date(drec.getTime() - (drec.getTimezoneOffset() * 60000)).toISOString().slice(0, 23).replace(\"T\", \" \");\nlet daterec = dateTimeLocal.slice(0, 10)\n\nlet datecom = new Date(msg.payload.date_comp_rga)\nlet dateTimeLocal1 = new Date(datecom.getTime() - (datecom.getTimezoneOffset() * 60000)).toISOString().slice(0, 23).replace(\"T\", \" \");\nlet datecomp = dateTimeLocal1.slice(0, 10)\n\nlet tof = new Date(msg.payload.to_office)\nlet dateTimeLocal2 = new Date(tof.getTime() - (tof.getTimezoneOffset() * 60000)).toISOString().slice(0, 23).replace(\"T\", \" \");\nlet gto = dateTimeLocal2.slice(0, 10)\n\nlet t = new Date(msg.payload.follow_up_meeting)\nlet dateTimeLocal3 = new Date(t.getTime() - (t.getTimezoneOffset() * 60000)).toISOString().slice(0, 23).replace(\"T\", \" \");\nlet tm = dateTimeLocal3.slice(0, 10)\n\nif (ar == \"Accepted\"){ar = true}\nif( ar == \"Rejected\"){ar = false}\nif(cont == \"Yes\"){cont= true}\nif(cont == \"No\"){cont= false}\n\n\nmsg.payload = {\"id\":id,\n    \"daterec\": daterec,\n\"rganum\":rganum,\n\"gw\":gw,\n\"comp\":comp,\n\"deft\":deft,\n\"datecomp\":datecomp,\n\"gto\":gto,\n\"dtp\":dtp,\n\"tm\":tm,\n\"dr\":dr,\n\"adp\":adp,\n\"ar\":ar,\n\"pump\":pump,\n\"cont\":cont,\n\"bear\":bear,\n\"bvend\":bvend,\n\"seal\":seal,\n\"svend\":svend,\n\"wo\":wo,\n\"dou\":dou,\n\"sct\":sct,\n\"db\":db,\n\"rc\":rc,\n\"mil\":mil,\n\"vin\":vin,\n\"dol\":dol,\n\"ask\":ask,\n\"comment\":comment}\n\nreturn msg;\n","outputs":1,"noerr":0,"initialize":"","finalize":"","libs":[],"x":1810,"y":300,"wires":[["ce6a32cbfc01a85b","36026c71718f994f"]]},{"id":"9dac474874231066","type":"debug","z":"9d60d084003b46ca","name":"","active":false,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1550,"y":360,"wires":[]},{"id":"9000c88741efd412","type":"split","z":"9d60d084003b46ca","name":"","splt":"\\n","spltType":"str","arraySplt":1,"arraySpltType":"len","stream":false,"addname":"","x":350,"y":200,"wires":[["eec17113c0fcb638","5fa145e8b4b4c68d"]]},{"id":"428cbc64c6ac3f6e","type":"join","z":"9d60d084003b46ca","name":"","mode":"custom","build":"array","property":"payload","propertyType":"msg","key":"topic","joiner":"\\n","joinerType":"str","accumulate":false,"timeout":"","count":"","reduceRight":false,"reduceExp":"","reduceInit":"","reduceInitType":"","reduceFixup":"","x":1070,"y":320,"wires":[["4a5c9a6be60b59f8","3483688aa2fe73f8"]]},{"id":"b72a583d68850910","type":"trigger","z":"9d60d084003b46ca","name":".","op1":"","op2":"","op1type":"nul","op2type":"str","duration":"250","extend":true,"overrideDelay":false,"units":"ms","reset":"","bytopic":"all","topic":"topic","outputs":1,"x":810,"y":380,"wires":[["6ca3223f0eaa5822"]]},{"id":"6ca3223f0eaa5822","type":"change","z":"9d60d084003b46ca","name":".","rules":[{"t":"delete","p":"payload","pt":"msg"},{"t":"set","p":"complete","pt":"msg","to":"","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":950,"y":380,"wires":[["428cbc64c6ac3f6e"]]},{"id":"5fa145e8b4b4c68d","type":"change","z":"9d60d084003b46ca","name":"","rules":[{"t":"change","p":"payload.acc_rej","pt":"msg","from":"1","fromt":"num","to":"Accepted","tot":"str"},{"t":"change","p":"payload.acc_rej","pt":"msg","from":"0","fromt":"num","to":"Rejected","tot":"str"},{"t":"change","p":"payload.contaminated","pt":"msg","from":"1","fromt":"num","to":"Yes","tot":"str"},{"t":"change","p":"payload.contaminated","pt":"msg","from":"0","fromt":"num","to":"No","tot":"str"}],"action":"","property":"","from":"","to":"","reg":false,"x":520,"y":320,"wires":[["428cbc64c6ac3f6e","b72a583d68850910"]]},{"id":"4a5c9a6be60b59f8","type":"switch","z":"9d60d084003b46ca","name":"","property":"payload","propertyType":"msg","rules":[{"t":"nempty"},{"t":"empty"}],"checkall":"true","repair":false,"outputs":2,"x":1210,"y":320,"wires":[["b7a0bd2eabc94be0","6aadc2e9e55a5cee"],["9dac474874231066"]]},{"id":"eec17113c0fcb638","type":"debug","z":"9d60d084003b46ca","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":570,"y":220,"wires":[]},{"id":"018c14e1477f7426","type":"inject","z":"9d60d084003b46ca","name":"trigger","props":[{"p":"payload"}],"repeat":"","crontab":"","once":false,"onceDelay":0.1,"topic":"","payload":"{\"id\":null,\"daterec\":\"2022-10-31\",\"rganum\":\"13293\",\"gw\":\"GW\",\"comp\":\"DIESEL FORWARD\",\"deft\":1,\"datecomp\":\"2022-11-22\",\"gto\":\"2022-11-22\",\"dtp\":16,\"tm\":\"\",\"dr\":\"\",\"adp\":0,\"ar\":true,\"pump\":\"18-2037\",\"cont\":false,\"bear\":\"81-WIR1630139W2\",\"bvend\":\"147\",\"seal\":\"81-106MAC\",\"svend\":\"48\",\"wo\":\"33559\",\"dou\":\"\",\"sct\":\"\",\"db\":\"4/20/2021\",\"rc\":19,\"mil\":\"\",\"vin\":\"\",\"dol\":\"\",\"ask\":null,\"comment\":\"Not Restock, Pump passed print measurement & pressure CTS test w/original o-ring @ -.02SCCM, silicone is built up on the o-ring from the customer\"}","payloadType":"json","x":230,"y":280,"wires":[["9000c88741efd412"]]},{"id":"b7a0bd2eabc94be0","type":"debug","z":"9d60d084003b46ca","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1550,"y":240,"wires":[]},{"id":"ce6a32cbfc01a85b","type":"ui_form","z":"9d60d084003b46ca","name":"","label":"Search Fields","group":"8220361faab44749","order":2,"width":12,"height":1,"options":[{"label":"id","value":"id","type":"number","required":false,"rows":null},{"label":"Date Rec","value":"daterec","type":"date","required":false,"rows":null},{"label":"RGA Number","value":"rganum","type":"text","required":false,"rows":null},{"label":"LC / GW","value":"gw","type":"text","required":false,"rows":null},{"label":"Company","value":"comp","type":"text","required":false,"rows":null},{"label":"Defects","value":"deft","type":"number","required":false,"rows":null},{"label":"Date Completed Rga","value":"datecomp","type":"date","required":false,"rows":null},{"label":"Date to Office","value":"gto","type":"date","required":false,"rows":null},{"label":"Days to Process","value":"dtp","type":"number","required":false,"rows":null},{"label":"Follow Up Meeting","value":"tm","type":"date","required":false,"rows":null},{"label":"Meeting Notes","value":"dr","type":"text","required":false,"rows":null},{"label":"Days To Credit","value":"adp","type":"number","required":false,"rows":null},{"label":"Accept?","value":"ar","type":"checkbox","required":false,"rows":null},{"label":"Pump #","value":"pump","type":"text","required":false,"rows":null},{"label":"Contaminated?","value":"cont","type":"checkbox","required":false,"rows":null},{"label":"Bearing Part #","value":"bear","type":"text","required":false,"rows":null},{"label":"Bearing Vendor","value":"bvend","type":"text","required":false,"rows":null},{"label":"Seal Part #","value":"seal","type":"text","required":false,"rows":null},{"label":"Seal Vendor","value":"svend","type":"text","required":false,"rows":null},{"label":"Work Order #","value":"wo","type":"text","required":false,"rows":null},{"label":"DOUWEI #","value":"dou","type":"text","required":false,"rows":null},{"label":"S.C. Trace","value":"sct","type":"text","required":false,"rows":null},{"label":"Date Built / Vendor Name","value":"db","type":"text","required":false,"rows":null},{"label":"Reason Code","value":"rc","type":"text","required":false,"rows":null},{"label":"Milage","value":"mil","type":"text","required":false,"rows":null},{"label":"VIN #","value":"vin","type":"text","required":false,"rows":null},{"label":"Refund Delivered","value":"dol","type":"text","required":false,"rows":null},{"label":"Asking Refund","value":"ask","type":"number","required":false,"rows":null},{"label":"Comments","value":"comment","type":"multiline","required":false,"rows":3}],"formValue":{"id":"","daterec":"","rganum":"","gw":"","comp":"","deft":"","datecomp":"","gto":"","dtp":"","tm":"","dr":"","adp":"","ar":false,"pump":"","cont":false,"bear":"","bvend":"","seal":"","svend":"","wo":"","dou":"","sct":"","db":"","rc":"","mil":"","vin":"","dol":"","ask":"","comment":""},"payload":"","submit":"submit","cancel":"cancel","topic":"topic","topicType":"msg","splitLayout":true,"className":"","x":2140,"y":300,"wires":[[]]},{"id":"7d21713fea51f9ed","type":"debug","z":"9d60d084003b46ca","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1790,"y":260,"wires":[]},{"id":"36026c71718f994f","type":"debug","z":"9d60d084003b46ca","name":"","active":true,"tosidebar":true,"console":false,"tostatus":false,"complete":"false","statusVal":"","statusType":"auto","x":1990,"y":260,"wires":[]},{"id":"8220361faab44749","type":"ui_group","name":"Search","tab":"4b9b9fcf6d5a669a","order":7,"disp":true,"width":12,"collapse":false,"className":""},{"id":"4b9b9fcf6d5a669a","type":"ui_tab","name":"Quality","icon":"","disabled":false,"hidden":false}]

I tried to add this function and it made it two days out.
let d = new Date(msg.payload.date) let dateTimeLocal = new Date(d.getTime() - (d.getTimezoneOffset() * 60000)).toISOString().slice(0,23).replace("T"," "); let dateLocal = dateTimeLocal.slice(0,10)

The database is local and is in central time America/chicgo time

OK, thanks.
I installed ui-table and your flow but I just get an empty form.
In this instance I was hoping for a snapshot of a date from the db, the way it gets displayed and it's value in further processing. :grinning:

It does look like you are just using dd/mm/yyyy part of the date object? I wondered if there was a timezone related time shift of -n hours.

Also, are you on an older version of Node-red? I am sure this problem is not related to the version, but in the current release all of those debug nodes automatically get unique names.

The trigger inject node should have all the information in it. It is coming from the database, so the data is in an array. Here is some data directly from the db

[{"id":46916,"date":"2022-10-31T00:00:00.000Z","rga_number":"13293","LC_GW":"GW","company":"DIESEL FORWARD","defects":1,"date_comp_rga":"2022-11-22T00:00:00.000Z","to_office":"2022-11-22T00:00:00.000Z","days_to_process":16,"follow_up_meeting":null,"date_rec":null,"days_to_credit":0,"acc_rej":1,"pump_number":"18-2037","contaminated":0,"bearing":"81-WIR1630139W2","b_vendor":147,"seal":"81-106MAC","s_vendor":48,"work_order":"33559","douwei_num":null,"sc_trace":null,"date_built_vendor":"4/20/2021","reason_code":"19","milage":null,"vin":"N","issued_refund":0,"asking_refund":0,"additional_comments":"Not Restock, Pump passed print measurement & pressure CTS test w/original o-ring @ -.02SCCM, silicone is built up on the o-ring from the customer"}]

node red is up to date as well as all of the modules