Questions about the MySQL, PostgreSQL, and most other databases, as well as using it with PHP can be asked here.
Moderator: General Moderators
-
itsmani1
- Forum Regular
- Posts: 791
- Joined: Mon Sep 29, 2003 2:26 am
- Location: Islamabad Pakistan
-
Contact:
Post
by itsmani1 »
how can i find exact time difference between current time and given time.
I tried both with php code and mysql statement
for exampel this qry:
Code: Select all
SELECT TIMEDIFF(CURDATE(),'2009:01:01 00:00:00');
gives me null
-
volka
- DevNet Evangelist
- Posts: 8391
- Joined: Tue May 07, 2002 9:48 am
- Location: Berlin, ger
Post
by volka »
Format of the "given date"?
What have you tried so far?
-
itsmani1
- Forum Regular
- Posts: 791
- Joined: Mon Sep 29, 2003 2:26 am
- Location: Islamabad Pakistan
-
Contact:
Post
by itsmani1 »
Code: Select all
SELECT TIMEDIFF(CURDATE(),'2009:01:01 00:00:00');
should this give NULL?
-
volka
- DevNet Evangelist
- Posts: 8391
- Joined: Tue May 07, 2002 9:48 am
- Location: Berlin, ger
Post
by volka »
-
feyd
- Neighborhood Spidermoddy
- Posts: 31559
- Joined: Mon Mar 29, 2004 3:24 pm
- Location: Bothell, Washington, USA
Post
by feyd »
This isn't even remotely a PHP question.
Shape up itsmani1; you've been here long enough.
-
arukomp
- Forum Contributor
- Posts: 113
- Joined: Sun Sep 24, 2006 4:22 am
Post
by arukomp »
Try this:
Code: Select all
SELECT TIMEDIFF(CURDATE(),'2009-01-01 00:00:00');
You have to use '-' in date and ':' in time. The date format was wrong, so it gave you a NULL