Issue when comparing result of to_char(myDate, 'DAY') to a string

后端 未结 2 1923
耶瑟儿~
耶瑟儿~ 2020-12-03 22:39

I have been trying to find what the issue might be but I am just out of luck and don\'t understand this problem at all.I have the following code:

CREATE OR R         


        
相关标签:
2条回答
  • 2020-12-03 23:11

    If you want to be really robust about this then you ought to force the NLS setting to English and apply the "fill mode" format model FM for trimming leading and trailing spaces.

    If To_Char(DateC,'fmDAY', 'nls_date_language=english') = 'FRIDAY'
    Then ...
    
    0 讨论(0)
  • 2020-12-03 23:14

    It is because day variable contains a blank padded value. Use trim function to get rid of leading and trailing spaces:

    IF trim(day) = 'FRIDAY' THEN
      checkFriday := 'Y';
    END IF;
    

    And please use VARCHAR2 datatype for string variables. Do not use VARCHAR.

    0 讨论(0)
提交回复
热议问题