How to set a Date / timestamp attribute on an item and update it in Postgres

Hi folks,

I’d like to update a Postgres row with the current time after a step has been completed, but I am having trouble passing the date in as a valid attribute for an item.

In a “Function Item” node, if I set a date field using something like this, either as a date object or a string:

item.updated_at = new Date();


item.updated_at = new Date().toISOString()

Then in the “Postgres” node, I do an update on my table, then I get a standard Postgres error back that the type of updated_at is a string, not a timestamp.

How do you correctly transform/represent a date attribute of an item in an update in the Postgres node?

Or is there another node that I should be using to write to the database? I’ve seen other posts where there is raw SQL being shared, but I can’t see where I would input that using the n8n user interface.

Hope someone can point me in the right direction! Thanks!

An alternative is to just use the standard SQL function current_timestamp:

insert into my_log(tz) values(current_timestamp);
1 Like

Thanks - yep, I realise that I could do this with an SQL query. But the actual UI component for the Postgres node doesn’t seem to have anything that lets you put in any SQL yourself. It seems to auto-generate the SQL query.

Perhaps I’m missing something here about how everyone else authors their n8n workflows?

I’m just editing the workflow using the browser, but would very much prefer to have this in a config file under version control!