Skip to content
Advertisement

How compare dates that are equal when one has time as well

I’m trying to compare dates and it looks like I’m doing it like examples online, but I only see the rows of dates returned when I do >= for the comparison. When I just use = it doesn’t return anything.

This is my query with >= for the date comparison:

I see a lot of this sort of thing returned:

I want it to do this: CRTUPDDT = to_date(’28-10-21′,’DD-MM-YY’) but that doesn’t return any rows.

I think the comparison as equals and not greater than has to do with the what is returned, but I’m not sure how to fix it. Also, I don’t want to see duplicate lines returned, but there’s so many that distinct makes it take forever.

This is a link I was looking at: date

Advertisement

Answer

Compare on a range over the entire day:

You could also compare using TRUNC:

However, if you have an index on CRTUPDDT then it would not be used in this latter query; you would need to have a function-based index on TRUNC(CRTUPDDT) instead.

User contributions licensed under: CC BY-SA
5 People found this is helpful
Advertisement