Thread: is there a way to get hh:mm:ss given seconds

is there a way to get hh:mm:ss given seconds

From
"Narendra A"
Date:
<div class="Section1"><p class="MsoNormal"><span class="EmailStyle15"><font color="black" face="Arial" size="2"><span
style="font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family:
Arial">Sir,</span></font></span><p class="MsoNormal"><span class="EmailStyle15"><font color="black" face="Arial"
size="2"><spanstyle="font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family: 
Arial">Is there a way in sql such that if I give seconds it should me return me
hours:mins:seconds</span></font></span><pclass="MsoNormal"><span class="EmailStyle15"><font color="black" face="Arial"
size="2"><spanstyle="font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family: 
Arial"> </span></font></span><p class="MsoNormal"><span class="EmailStyle15"><font color="black" face="Arial"
size="2"><spanstyle="font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family: 
Arial">Eg. Seconds<span style="mso-tab-count:1">     </span>hh:mm:ss</span></font></span><p class="MsoNormal"
style="margin-left:1.0in;text-indent:-.5in;mso-list:l0level1 lfo1; 
tab-stops:list 1.0in"><span class="EmailStyle15"><font color="black" face="Arial" size="2"><span
style="font-size:10.0pt;mso-bidi-font-size:
12.0pt;font-family:Arial">422<font face="Times New Roman" size="1"><span style="font:7.0pt "Times New
Roman"">             </span></font></span></font></span><span class="EmailStyle15"><font color="black" face="Arial"
size="2"><spanstyle="font-size:10.0pt;mso-bidi-font-size: 
12.0pt;font-family:Arial">1:01:02</span></font></span><p class="MsoNormal"><span class="EmailStyle15"><font
color="black"face="Arial" size="2"><span style="font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family: 
Arial"> </span></font></span><p class="MsoNormal"><span class="EmailStyle15"><font color="black" face="Arial"
size="2"><spanstyle="font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family: 
Arial">eagerly waiting for response.</span></font></span><p class="MsoNormal"><span class="EmailStyle15"><font
color="black"face="Arial" size="2"><span style="font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family: 
Arial"> </span></font></span><p class="MsoNormal"><span class="EmailStyle15"><font color="black" face="Arial"
size="2"><spanstyle="font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family: 
Arial">Regards</span></font></span><p class="MsoNormal"><span class="EmailStyle15"><font color="black" face="Arial"
size="2"><spanstyle="font-size:10.0pt;mso-bidi-font-size:12.0pt;font-family: 
Arial">Narendra</span></font></span></div><br /> DISCLAIMER: This email is bound by the terms and conditions described
at<br /> http://www.subexgroup.com/mail-disclaimer.htm<br /> 

Re: is there a way to get hh:mm:ss given seconds

From
David Stanaway
Date:
On Mon, 2002-07-08 at 09:28, Narendra A wrote:
> Sir,
> Is there a way in sql such that if I give seconds it should me return me
> hours:mins:seconds
>
> Eg. Seconds     hh:mm:ss
> 422              1:01:02


scratch=# SELECT 422::interval;interval
----------00:07:02
(1 row)

scratch=# \q
dstanawa@ciderbox:~$ bc -l
7*60+2
422

I don't know where you got 1:01:02 from.


--
David Stanaway

Re: is there a way to get hh:mm:ss given seconds

From
Tod McQuillin
Date:
On Mon, 8 Jul 2002, Narendra A wrote:

> Is there a way in sql such that if I give seconds it should me return me
> hours:mins:seconds
>
> Eg. Seconds     hh:mm:ss
> 422              1:01:02

foo=# select '422 seconds'::interval;interval
----------00:07:02
(1 row)
-- 
Tod McQuillin






Re: is there a way to get hh:mm:ss given seconds

From
Kevin Brannen
Date:
Tod McQuillin wrote:
> On Mon, 8 Jul 2002, Narendra A wrote:
> 
> 
>>Is there a way in sql such that if I give seconds it should me return me
>>hours:mins:seconds
>>
>>Eg. Seconds     hh:mm:ss
>>422              1:01:02
> 
> 
> foo=# select '422 seconds'::interval;
>  interval
> ----------
>  00:07:02
> (1 row)


That works on inserts into a "time" field too, cool tip.  THANKS!

Kevin



Re: is there a way to get hh:mm:ss given seconds

From
"Josh Berkus"
Date:
Narendra,

> I tried all these. This is what I get
> SQL> SELECT "interval"(cast(422 as varchar) || ' seconds');
> SELECT "interval"(cast(422 as varchar) || ' seconds')
>                                      *
> ERROR at line 1:
> ORA-00906: missing left parenthesis

> SQL> select '422 seconds'::interval;
> select '422 seconds'::interval
>                     *
> ERROR at line 1:
> ORA-00923: FROM keyword not found where expected

Those don't look like PostgreSQL error messages.  I think you are using
some other database.

-Josh Berkus


Re: is there a way to get hh:mm:ss given seconds

From
"Christopher Kings-Lynne"
Date:
> > I tried all these. This is what I get
> > SQL> SELECT "interval"(cast(422 as varchar) || ' seconds');
> > SELECT "interval"(cast(422 as varchar) || ' seconds')
> >                                      *
> > ERROR at line 1:
> > ORA-00906: missing left parenthesis
> 
> > SQL> select '422 seconds'::interval;
> > select '422 seconds'::interval
> >                     *
> > ERROR at line 1:
> > ORA-00923: FROM keyword not found where expected
> 
> Those don't look like PostgreSQL error messages.  I think you are using
> some other database.

Yes - he's using Oracle.  I think Narendra is rather confused...

Chris