This is the most important section:
"" AS ValidForPeriod, Date() Is Null AS ExpiryDate, "No" AS RuleExpired, "" AS [Value], "" AS ReminderDate, "" AS RuleReminder, "" AS SkillsMaintenance,
Most of those are being set to empty String values, so will be treated as text based.

The condition for ExpiryDate (Date() Is Null) actually makes it a Boolean, and due to the condition will always return False (the function Date() will always return an actual value, never a Null). What you should have for it is this:
Code:
, Null AS ExpiryDate