Page 1 of 1

date diff?

Posted: Tue Feb 08, 2005 5:44 am
by itsmani1
how to find date differance?
like
date1, date2
i hav to this with qry
--------------------------------
select field where date diff is between 31 days?
--------------------------------
any help?

Posted: Tue Feb 08, 2005 5:53 am
by anjanesh
In MySQL,

Code: Select all

UNIX_TIMESTAMP(date1)-UNIX_TIMESTAMP(date2) AS DiffTime
will give the difference in time in UnixTimestamp format

Posted: Tue Feb 08, 2005 5:58 am
by itsmani1
anjanesh wrote:In MySQL,

Code: Select all

UNIX_TIMESTAMP(date1)-UNIX_TIMESTAMP(date2) AS DiffTime
will give the difference in time in UnixTimestamp format
i guess it will giv time
i need days
means:

select field1 where date1-date2 > 20 days

what about this thing?

Posted: Tue Feb 08, 2005 6:05 am
by itsmani1
SELECT DATEDIFF('1997-12-31 23:59:59','1997-12-30');
i tried this one
i m working on 1.2 version of mysql
and its not working there...

Posted: Tue Feb 08, 2005 6:07 am
by anjanesh
60 secs x 60 min x 24 hrs
(UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(Entry))/(60*60*24) AS DiffTimeInDays

Posted: Tue Feb 08, 2005 1:44 pm
by mudkicker
TO_DAYS(date1) - TO_DAYS(date2) <= $numberofdifference