Might be this will help you:
there is a table called message with 3 colums - id, pubdate and message;
You can get all messages from the last 5 minutes with the following example;

SELECT TIMESTAMPDIFF(MINUTE, pubdate, now()), id, message from message where
(TIMESTAMPDIFF(MINUTE, pubdate, now()) < 5);

Thanks,

On Fri, Mar 5, 2010 at 8:19 PM, Tompkins Neil
<neil.tompk...@googlemail.com>wrote:

> Hi
>
> I have a number of rows which have Date and Time data in.  I want to
> display
> in the following formats based on the systems current time
>
> e.g under 1 hour 24min ago
> e.g under 1 day 16h 29min ago
> e.g over 1 day 1d 2h 29min ago
> e.g over 1 week 1w 4d 2h 29min ago
>
> How would this best be achieve using MySQL.
>
> Thanks,
> Neil
>



-- 
Best Regards,

Prabhat Kumar
MySQL DBA
Datavail-India Mumbai
Mobile     : 91-9987681929
www.datavail.com

My Blog: http://adminlinux.blogspot.com
My LinkedIn: http://www.linkedin.com/in/profileprabhat

Reply via email to