user1638487
user1638487

Reputation: 63

SQL Compare date

Hi guys I am trying to compare the local date with one of my query , the problem is that I don't know how to do that .

As I know if we run this

SELECT NOW()

It will output something like this 2013-03-23 06:56:55

Now I'd like to update one my row comparing that info but I don't know how to, my idea it's something like this

UPDATE `account`.`account` SET `Level` = '1' 
WHERE `Level` = '2' AND Select NOW() >`last_online`

What I want to prevent is the fact that I am updating the account and the user is online , so I want to compare the last time online with the current date and then run the query if the current date is > than the last time online

Thanks!

EDIT: The server is mysql

Upvotes: 1

Views: 320

Answers (1)

acutesoftware
acutesoftware

Reputation: 1091

Try removing the 2nd SELECT

  UPDATE `account`.`account` 
  SET `Level` = '1' 
  WHERE `Level` = '2' AND NOW() > `last_online` 

Upvotes: 2

Related Questions