pg.ddx.io  pgsql-sql@postgresql.org mailing list archive  
help / color / mirror / Atom feed
Time formating
2+ messages / 2 participants
[nested] [flat]

* Time formating
@ 2003-05-02 22:33  Katka a Daniel Dunajsky <daniel_katka@hotmail.com>
  0 siblings, 1 reply; 2+ messages in thread

From: Katka a Daniel Dunajsky @ 2003-05-02 22:33 UTC (permalink / raw)
  To: pgsql-sql

Hello All,

This question is related to my preceeding question.

How to format a value 7383 to represent 02H:03M:03SS (hours-minutes-seconds) 
using postgresql?

I have this query:

SELECT SUM (session_length))/60)/60 AS "Total",
FROM   user_sessions
WHERE  TO_CHAR(session_start, 'YYYY-MM') = '2003-04';

If session_length = 7383 I will receive 2.


I have received advice that I should use . and it will work with

select 5./2, however how to do it when I have a variable?

Thank you for your time.

Daniel



_________________________________________________________________
The new MSN 8: advanced junk mail protection and 2 months FREE*  
http://join.msn.com/?page=features/junkmail




^ permalink  raw  reply  [nested|flat] 2+ messages in thread

* Re: Time formating
@ 2003-05-02 23:11  Stephan Szabo <sszabo@megazone23.bigpanda.com>
  parent: Katka a Daniel Dunajsky <daniel_katka@hotmail.com>
  0 siblings, 0 replies; 2+ messages in thread

From: Stephan Szabo @ 2003-05-02 23:11 UTC (permalink / raw)
  To: Katka a Daniel Dunajsky <daniel_katka@hotmail.com>; +Cc: pgsql-sql


On Fri, 2 May 2003, Katka a Daniel Dunajsky wrote:

> Hello All,
>
> This question is related to my preceeding question.
>
> How to format a value 7383 to represent 02H:03M:03SS (hours-minutes-seconds)
> using postgresql?
>
> I have this query:
>
> SELECT SUM (session_length))/60)/60 AS "Total",
> FROM   user_sessions
> WHERE  TO_CHAR(session_start, 'YYYY-MM') = '2003-04';
>
> If session_length = 7383 I will receive 2.

A better way would probably be something like:
SELECT INTERVAL '1 second' * session_length AS "Total"
 ...


> I have received advice that I should use . and it will work with
>
> select 5./2, however how to do it when I have a variable?

Use a cast of the general form CAST(<variable> as <type>).




^ permalink  raw  reply  [nested|flat] 2+ messages in thread


end of thread, other threads:[~2003-05-02 23:11 UTC | newest]

Thread overview: 2+ messages (download: mbox mbox.gz follow: Atom feed)
-- links below jump to the message on this page --
2003-05-02 22:33 Time formating Katka a Daniel Dunajsky <daniel_katka@hotmail.com>
2003-05-02 23:11 ` Stephan Szabo <sszabo@megazone23.bigpanda.com>

This inbox is served by DDX for PostgreSQL; see mirroring instructions
for how to clone and mirror all data and code used for this inbox