Closed mmoo-Leon-Sanders closed 2 weeks ago
iif(something, '0', '')
returns CHAR(1)
, because it's a "common" data type both values can be safely converted into. Thus the empty string is padded with a single space, this is the standard behavior of CHAR
. This is by design and affects all FB versions since 1.5 IIRC.
version Firebird-5.0.0.1306-0-linux-x64.tar.gz run select iif(extract(month from '2024-10-01')<10,'0','')||extract(month from '2024-10-01') from rdb$database or select iif(extract(month from '2024-10-01')>9,'','0')||extract(month from '2024-10-01') from rdb$database
returns ' 10' and not '10' there is a preceding space where the iif statement requests '' on false in the first statement or true in the second if you place '#' for example it works returning '#10' but empty string add a space
for now, I use select iif(extract(month from '2024-10-01')<10,'0',trim(''))||extract(month from '2024-10-01') from rdb$database