aspose file tools*
The moose likes JDBC and the fly likes converting a mysql DATETIME (HH:mm:ss) to seconds Big Moose Saloon
  Search | Java FAQ | Recent Topics | Flagged Topics | Hot Topics | Zero Replies
Register / Login
JavaRanch » Java Forums » Databases » JDBC
Bookmark "converting a mysql DATETIME (HH:mm:ss) to seconds" Watch "converting a mysql DATETIME (HH:mm:ss) to seconds" New topic
Author

converting a mysql DATETIME (HH:mm:ss) to seconds

jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
Hi,

My sql command below gives me; hh:mm:ss - like so - 01:04:16



how do i convert this result to seconds?........do i have to use string manipulation!
Jeanne Boyarsky
author & internet detective
Marshal

Joined: May 26, 2003
Posts: 30777
    
157

What does it mean to convert a date to seconds? For example, how many seconds would 4:34:12 be?


[Blog] [JavaRanch FAQ] [How To Ask Questions The Smart Way] [Book Promos]
Blogging on Certs: SCEA Part 1, Part 2 & 3, Core Spring 3, OCAJP, OCPJP beta, TOGAF part 1 and part 2
jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
I found the difference between two datetime values:


and i pretty sure what i got back was hr min and sec.

I suppose, 4hr 34minutes and 12seconds = 14,400 + 2040 + 12 sec
jite eghagha
Ranch Hand

Joined: Oct 06, 2006
Posts: 127
thanks, i resolved my question using an mysql command: TIME_TO_SEC(time)

documented here:time_to_sec

so by adding that to the sql statment, i can calculate the number of seconds that passed between two datetime values.

 
Consider Paul's rocket mass heater.
 
subject: converting a mysql DATETIME (HH:mm:ss) to seconds