s_mj
s_mj

Reputation: 580

add time interval with value from selected column in postgres

I am new in Postgres and want to know if there is a better way to solve time interval problem in Postgres.

In MySQL i have:

Select STR_TO_DATE(start_time - interval (tkc + tct) second + interval 3 hour, '%Y-%m-%d %H:%i:%s') as start_time 
from table

For Postgres I found and wrote query as:

select start_time - (interval  '1 second' * (tkc + tct)) + interval  '3 hour' 
from table

Upvotes: 2

Views: 824

Answers (1)

s_mj
s_mj

Reputation: 580

Thanks for all the answers. Wonderful to be part of community.

I was able to solve this as below.

select start_time - ((tkc + tct)|| ' seconds')::interval + interval '3 hour' as start_time from table

Upvotes: 4

Related Questions