I have a Varchar day column and I would like to select all rows where the day from day column matches current day in the system. I came up with this query but it didn’t find any match, although today is Thursday and there is Thursday stored in the day column. I’m not sure if this is the right way to compare date data type with varchar.
select * from schedule
where day = (select to_char(sysdate,'day') from dual);
I think the problem comes from the fact that
to_charfunctions are space-padded by default:To prevent padding, use the prefix
fm:Also note that VARCHAR comparison is case-sensitive.