• Post Reply Bookmark Topic Watch Topic
  • New Topic
programming forums Java Mobile Certification Databases Caching Books Engineering Micro Controllers OS Languages Paradigms IDEs Build Tools Frameworks Application Servers Open Source This Site Careers Other Pie Elite all forums
this forum made possible by our volunteer staff, including ...
Marshals:
  • Campbell Ritchie
  • Paul Clapham
  • Ron McLeod
  • Jeanne Boyarsky
  • Tim Cooke
Sheriffs:
  • Liutauras Vilda
  • paul wheaton
  • Henry Wong
Saloon Keepers:
  • Tim Moores
  • Tim Holloway
  • Stephan van Hulst
  • Carey Brown
  • Frits Walraven
Bartenders:
  • Piet Souris
  • Himai Minh

Total Time duration

 
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Hi ALL,
I need to get total time duration of my user in my application. I got maximum time duration he has spent for a month from the below sample query .




The output I got as below:
siteDuration---------------->::00:00:24
siteDuration---------------->::00:00:05
siteDuration---------------->::00:00:09
siteDuration---------------->::00:00:14
siteDuration---------------->::00:51:33
siteDuration---------------->::00:16:42
siteDuration---------------->::00:00:05
siteDuration---------------->::00:00:25
siteDuration---------------->::00:00:05
siteDuration---------------->::00:00:10
siteDuration---------------->::00:00:09
siteDuration---------------->::00:03:02
siteDuration---------------->::00:00:18
siteDuration---------------->::00:00:11

I need to total all the times mentioned above and get the result as total duration time. How it is possible in java?
I have tried with Sum function in SQl, but it will not total the time(HH:MM:SS), it can total only the integer values. The resultset i am getting is set of all the max time duration the user has spent for a month, so i need to total all the values and get the output as single Time in HH:MM:SS format.
Help in java code is appreciated.
 
Ranch Hand
Posts: 1923
Scala Postgres Database Linux
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
Simplifying your statement (removing needless intermediate StringBuffer):



I'm asking, how this query might return multiple rows?
You don't have a GROUP clause, so SELECT MAX (x) FROM (y) should return just one value - the maximum.

Probably you're hiding something here?

and you tried

without success?
 
sundar sankaran
Greenhorn
Posts: 10
  • Mark post as helpful
  • send pies
    Number of slices to send:
    Optional 'thank-you' note:
  • Quote
  • Report post to moderator
I thought the fully query is not important. The resultset i am getting is set of all the max time duration the user has spent for a month, so i need to total all the values and get the output as single Time in HH:MM:SS format. Hope this clarifies your doubts. This is my query:
 
Today's lesson is that you can't wear a jetpack AND a cape. I should have read this tiny ad:
Free, earth friendly heat - from the CodeRanch trailboss
https://www.kickstarter.com/projects/paulwheaton/free-heat
reply
    Bookmark Topic Watch Topic
  • New Topic