Reputation: 3
I have a table with the fields timeout
and timein
. I need to return a list of records where timeout
is on a different day to timein
. How can I achieve this?
Upvotes: 0
Views: 208
Reputation: 8709
If both dates are in the same month, then:
select *
from table
where DAY(timeout) <> DAY(timein0)
or
select *
from table
where DATEPART(day,timeout) <> DATAPART(day,timein) or
will work..
If, however, they can be in different months, then you need to compare the full dates. This should do that for you:
select *
from table
where DATEDIFF(day,timeout,timein) <> 0
Upvotes: 3
Reputation: 36591
How about this :
select *
from table
where day(timeout) != day(timein);
Upvotes: 0
Reputation: 204
select *
from table_name
where datediff(dd,timein,timeout) > 0 (for day in greater then today)
if want next day time out then
select *
from table_name
where datediff(dd,timein,timeout) =1
Upvotes: 1