Thread: Adding a stored number of minutes to a stored time

Adding a stored number of minutes to a stored time

From
"Rob Richardson"
Date:

Greetings!

 

All of the examples I can find for adding a number of minutes to a timestamp show the number of minutes being hard-coded in the query.  I have a table that has a column containing a starting time and another column containing the number of minutes until the process will be finished.  I want to add the starting time and the number of minutes to calculate the finish time.  How do I convert the minutes column from an int4 to an interval?  Or is there a different way I should do that?

 

Thanks very much!

 

RobR

Re: Adding a stored number of minutes to a stored time

From
Michael Glaesemann
Date:
On Mar 28, 2011, at 9:06, Rob Richardson wrote:

> Greetings!
>
>
>
> All of the examples I can find for adding a number of minutes to a
> timestamp show the number of minutes being hard-coded in the query.  I
> have a table that has a column containing a starting time and another
> column containing the number of minutes until the process will be
> finished.  I want to add the starting time and the number of minutes to
> calculate the finish time.  How do I convert the minutes column from an
> int4 to an interval?  Or is there a different way I should do that?

select some_timestamp_value + int4_col * interval '1 minute'

Michael Glaesemann
grzm seespotcode net




Re: Adding a stored number of minutes to a stored time

From
"Rob Richardson"
Date:
Ah, yes.  Multiple a known interval by the number of them I need.  That
was the trick I had forgotten.  Thanks very much!

RobR