+ 1

Comparing CHAR with VARCHAR2

Why can't I compare data types v_day1 CHAR(10) against v_day2 VARCHAR2(10) when I've assigned to them today's day of the week using to_char(sysdate, 'day'); ? Another scenario is also writing a block comparing v_day2 with 'tuesday'... As in if v_day2 = 'tuesday' then /* output some text */. When I do this test with v_day1 which is CHAR(10) instead of v_day2 VARCHAR2(10) then the test passes with today being tuesday. Why is this? Even when I've assigned the values in the same way. Thanks in advance!

24th Apr 2018, 8:48 AM
Shelton
Shelton - avatar
2 ответов
+ 1
Thanks the rtrim worked but I still don't see what goes wrong when you are using the same assignment method to get the current day, as in why would it give you the name of the day with white spaces.
25th Apr 2018, 8:14 AM
Shelton
Shelton - avatar