PostgreSQL: Add a numerical number of seconds to a timestamp -


the problem

consider table 2 fields: timestamp dubbed creation_time , integer number of seconds dubbed expiration_time_seconds. hence,

select creation_time, expiration_time_seconds items; 

gives:

       creation_time        | expiration_time_seconds ----------------------------+-------------------------  2014-11-18 05:38:05.368598 |                    3600  2014-11-19 21:38:10.380777 |                 2592000  2014-11-19 21:41:28.152839 |                    3600  2014-11-18 17:15:11.501205 |                    3600  2014-11-19 21:43:38.815154 |                    3600  ... 

how add expiration time creation time expiration time?

what i've tried

creating interval constant text easy:

select creation_time+interval '3600 seconds' question; 

which gives:

          ?column? ----------------------------  2014-11-18 06:38:05.368598  2014-11-19 22:38:10.380777  2014-11-19 22:41:28.152839  ... 

but failed use custom text or integer interval.

multiply constant interval expiration_time_seconds column:

select creation_time+interval '1 second'*expiration_time_seconds items; 

credit: re: create interval using column value?, postgresql forums


Comments

Popular posts from this blog

angularjs - ADAL JS Angular- WebAPI add a new role claim to the token -

php - CakePHP HttpSockets send array of paramms -

node.js - Using Node without global install -