How to add a variable number of hours to a date in PostgreSQL?

前端 未结 4 672
攒了一身酷
攒了一身酷 2020-12-29 18:46

Apparently, PostgreSQL doesn\'t have DATEADD, because you can just use the + or - operators.

I need to add a number of hours t

4条回答
  •  天命终不由人
    2020-12-29 19:09

    Since you want to add hours, it should rather be:

    SELECT date_field + interval '1h' * start_time
    

    start_time can be any numerical value.

提交回复
热议问题