Win a copy of Mesos in Action this week in the Cloud/Virtualizaton forum!
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic

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

 
jite eghagha
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 34401
346
Eclipse IDE Java VI Editor
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
What does it mean to convert a date to seconds? For example, how many seconds would 4:34:12 be?
 
jite eghagha
Ranch Hand
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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
Posts: 128
  • Mark post as helpful
  • send pies
  • Quote
  • Report post to moderator
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.

 
  • Post Reply
  • Bookmark Topic Watch Topic
  • New Topic