PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
Moderator: General Moderators
itsmani1
Forum Regular
Posts: 791 Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:
Post
by itsmani1 » Tue Feb 08, 2005 5:44 am
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?
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Tue Feb 08, 2005 5:53 am
In MySQL,
Code: Select all
UNIX_TIMESTAMP(date1)-UNIX_TIMESTAMP(date2) AS DiffTime
will give the difference in time in UnixTimestamp format
itsmani1
Forum Regular
Posts: 791 Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:
Post
by itsmani1 » Tue Feb 08, 2005 5:58 am
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?
itsmani1
Forum Regular
Posts: 791 Joined: Mon Sep 29, 2003 2:26 am
Location: Islamabad Pakistan
Contact:
Post
by itsmani1 » Tue Feb 08, 2005 6:05 am
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...
anjanesh
DevNet Resident
Posts: 1679 Joined: Sat Dec 06, 2003 9:52 pm
Location: Mumbai, India
Post
by anjanesh » Tue Feb 08, 2005 6:07 am
60 secs x 60 min x 24 hrs
(UNIX_TIMESTAMP(NOW())-UNIX_TIMESTAMP(Entry))/(60*60*24) AS DiffTimeInDays
mudkicker
Forum Contributor
Posts: 479 Joined: Wed Jul 09, 2003 6:11 pm
Location: Istanbul, TR
Contact:
Post
by mudkicker » Tue Feb 08, 2005 1:44 pm
TO_DAYS(date1) - TO_DAYS(date2) <= $numberofdifference