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

前端 未结 4 681
攒了一身酷
攒了一身酷 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:02

    The one worked for me is

    SELECT date_field + interval '1' HOUR * start_time
    

    start_time can be any numerical value.

提交回复
热议问题