Home/Login   [ ReviewsQ & AHot off the WebForum ]   RegisterContact us
Log in to post content
Questions and Answers

Return to questions

What can you use instead of timestampdiff on MySQL 4.0.20?

Lenny (8)   794 days ago
computers, databases, mysql, programming


I have written an application using timestampdiff to work out the seconds‚ minutes and hours since something was done.  Unfortunately however I went to upload it on our production servers and found that as they only have MySQL 4.0.20 on them‚ they don't support this.  What can I use instead?
LinksAnswers


Other Questions

How can I overcome mod_security not allowing me access to some of my url's?
I have noticed that some of the urls on my site don't come up properly.  When I click on them apache comes up with:  
An appropriate representation of the requested resource...
  and giv…

How can I delete a feed from Rhythmbox?
I have been looking around Rhythmbox and can't find a way to delete feeds that I now longer want.  I can delete the episodes‚ but can't stop the feed from updating.  I am using this un…

What's the name of the film with James Cagney in it‚ where he says "Made it‚ Ma! Top of the world"?
I remember seeing this film a long time ago‚ but can't remember what it is called.  He says the above quote just before the oil tank he is standing on blows up.

What can you use instead of timestampdiff on MySQL 4.0.20?
I have written an application using timestampdiff to work out the seconds‚ minutes and hours since something was done.  Unfortunately however I went to upload it on our production servers and fo…

Where does your lap go when you stand up??



0
Telamon (4)
753 days ago
You could try using something like the following:
 

floor(time_to_sec(timediff(now()‚sometable.date))/60/60) as hours_ago
floor(time_to_sec(timediff(now()‚sometable.date))/60) as minutes_ago

floor(time_to_sec(timediff(now()‚sometable.date))) as seconds_ago
 
Where 'sometable' is the table and 'date' is the column you want to check the difference of.

1
Hobbit (0)
748 days ago
To improve on a previous answer‚ you could change the  
/60/60
  for hours to  
/3600
  as follows:
 

floor(time_to_sec(timediff(now()‚sometable.date))/3600) as hours_ago
floor(time_to_sec(timediff(now()‚sometable.date))/60) as minutes_ago

floor(time_to_sec(timediff(now()‚sometable.date))) as seconds_ago
 
Where 'sometable' is the table and 'date' is the column you want to check the difference of.


Useful Links




AdGridwork