I need to enter the postgres server time in a transaction group table

Hello, I am filling a postgres table and I have a field called “moment” type timestamp
It has to hold the date and time of the postgres database server, not the date and time of ignition Server.
Using SQL I would do it like this: insert into TABLE (moment,temperature)values(‘3.15’ , now())
But I don’t know how to do it with a transaction group which is what I need to use

Can someone help me?

Thank you

2 options:

  • An expression item querying the db for the current timestamp. This makes two round trips to the db, which is not ideal.

  • Adjust the setting of the momento column to have the default value of current_timestamp (using the db software of your choice). No extra trips to the db

alter table table_name
    alter column t_stamp set default current_timestamp;

Note: I think you can use either current_timestamp or now(). Both work on the version of postgres I’m using.

3 Likes