Обсуждение: is there a way to get hh:mm:ss given seconds
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
eagerly waiting for response.
Regards
Narendra
DISCLAIMER: This email is bound by the terms and conditions described at
http://www.subexgroup.com/mail-disclaimer.htm
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
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
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
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
> > 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