in reply to SQL query using elements from array

As an aside to the problem you are posting about (which is answered) why are you converting (with fn_sqlvarbasetostr) what looks like a timestamp to a string to compare with a string timestamp? Why not forget fn_sqlvarbasetostr and simply make your timestamps like "{ts '1998-05-02 01:23:56.123'}". You can omit the milliseconds.