Comparing 2 datetime in mysql

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

Post Reply
xiaomahe
Forum Newbie
Posts: 11
Joined: Sun Jun 28, 2009 10:14 am

Comparing 2 datetime in mysql

Post by xiaomahe »

I have one table called member, and i have 2 column called date and date1

how i can substract the 2 of them, date1-date > 0??

i tried TIMEDIFF, but could not make it, because nothing happened in my server

if($dateasd =mysql_query("SELECT * TIMEDIFF ('date1', 'date') FROM member")>0)
{
$login=0;
}

is there something wrong in how i define the variable?
User avatar
requinix
Spammer :|
Posts: 6617
Joined: Wed Oct 15, 2008 2:35 am
Location: WA, USA

Re: Comparing 2 datetime in mysql

Post by requinix »

How do you write the name of a field (or table, or database) in a SQL query?
How do you write a string value?

Which of those methods did you use for TIMEDIFF?
Which one should you have used?
Post Reply