Reputation: 580
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
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