Korenron
Korenron

Reputation: 101

mysql and c# - compare date with today (just the day)

I have a colomn name LastOnline which is define as DataType=Datetime I enter him the values as

update office.router set LastOnline=NOW() where IP=deviceip;

working as should

but how do I compare it to check only devices that aren't online today without the time , just the date part of the timestamp?

so when he will get ping from him today, he will try to ping it the next day?

I have try

    SELECT
*
FROM  office.router
where
LastOnline != Date(curdate())

but it didn't work - gave me the full list what is wrong?

Upvotes: 0

Views: 224

Answers (2)

A. Colonna
A. Colonna

Reputation: 872

You haven't to do date of curdate() because curdate is already a date:

SELECT * FROM sample.table1
where Date(LastOnline) = curdate()

Upvotes: 1

Korenron
Korenron

Reputation: 101

thanks , this is the correct way to write this:

SELECT
*
FROM sample.table1
where
Date(LastOnline) = Date(curdate())

working

Upvotes: 0

Related Questions