Home > other >  Joining two columns (type date, and type string) into another column in the same table (type timesta
Joining two columns (type date, and type string) into another column in the same table (type timesta

Time:09-17

I am having problems updating my table 'appointments' in postgreSQL. The table has a column date (type date) and a column time (type string). I need to join these two columns, and insert the value into a column starts_at (type timestamp) in the same table 'appointments'. I am having problems with finding the appropriate syntax to achieve that.

Any ideas?

Kind regards.

CodePudding user response:

If the time value is a properly formatted ISO time (e.g. '19:45:38'), you can cast it to a time value and add it to the date value to get a timestamp:

update appointments
    set starts_at = the_date_column   cast(the_time_column as time)
  • Related