List:General Discussion« Previous MessageNext Message »
From:toxalot Date:February 7 2000 4:44am
Subject:DATE_ADD
View as plain text  
I've been reading about DATE_ADD(date,INTERVAL expr type)  and it sounds
like just what I need, I think.

Can DATE_ADD be used in the WHERE clause too?  Does date have to be a
string or can it be a column name?

I want to test the users last_login time to see how long he has been logged
in.

Something like:

$sql="SELECT last_login FROM subscribers WHERE
user_name='$ENV{'REMOTE_USER'}' AND CURRENT_TIMESTAMP >
DATE_ADD(last_login, INTERVAL 1 HOUR)";
	$sth = $dbh->prepare($sql);
	$rv=$sth->execute();
	$rowref = $sth->fetchrow_hashref ();
   $sth->finish();
	if ($rv != 0) {&error ("Your log in session has timed out.  Your last
login was at $rowref->{'last_login'}. You will need to <a
href=\"$login_page\">log in</a> again.<br>\n");}
	else {
		$session_current = 1;
	}

Would this work?  I can't even test it yet because I don't have version
3.22 on my server yet.  My host has upgraded some servers, but not mine.

If they don't upgrade soon, what other options do I have to do this?

Jennifer


Thread
DATE_ADDtoxalot7 Feb