Page 1 of 1

Time Difference

Posted: Sun Aug 08, 2004 1:56 pm
by anjanesh
I wanted to find out the no: of days elapsed since it was entered
select DATE_FORMAT(now()-20040807111937,"%D")
returns NULL.
I know DATE_SUB can be used but I was just wondering why this is returning null when now()-20040807111937 is returning a no:
Any Ideas ?
Thanks

Posted: Sun Aug 08, 2004 2:05 pm
by feyd
try using one of the diff or timestamp functions: http://dev.mysql.com/doc/mysql/en/Date_ ... tions.html

Posted: Sun Aug 08, 2004 2:13 pm
by anjanesh
Actually the solution to this is DATEDIFF(expr,expr2) which I discovered before posting. But its supported only from ver 4.1.1 and my host provides ver 3.23. So I've to code for that.

What can be done manually is something like
SELECT (20040807111937 - now()) /(3600 *24) giving the number of days