OK. this looks like the first record you find is already in trouble.
I'd expect your data type is something else then stored.
Next omit the conversion %ODBCOUT()  just to see what internal content is and where it starts

  select ID,%INTERNAL(VerzamelDatTijd),
        DateTijdSec from GLPPatTcActie
         where pnr = '27085070017'
         and LTestId->Makey='BLA'
         and glpactieid->makey in ('TAV','TMA')
 

The next question is of course which program writes these values? and how? what's the source?

I get more and more the impression that some 'aged' program writes directly into the global.
Probably directly some $HOROLOG which is a combined %DATE,%TIME construct.

 

OK!
Now I see the problem. Each datatype has its specific conversion from internal format to ODBC format
So if VerzamelDatTijd is %Date or %Time or %Timestamp and the stored content doesn't fit
you get most likely this error.
It could be by principle := it fits never, a design issue
It could be just a glitch in some data record.
I suggest you start the SQL shell from terminal prompt.  USER>do $system.SQL.Shell()
And then run your modified query:

select  ID,%INTERNAL(VerzamelDatTijd),%ODBCout(VerzamelDatTijd),DateTijdSec
from  GLPPatTcActie 
 where pnr = '27085070017' and LTestId->Makey='BLA'
-- and VerzamelDatTijd < '2021-03-04 09:04'
and glpactieid->makey in ('TAV','TMA')
--
order by DateTijdSec desc

ID shows the flaky record
%INTERNAL() shows the raw content
%ODBCOUT() should trigger the error

Once you know the content you should be able to fix it.

Hi @Fábio Campos 
I see your problem. I don't assume that "Portuguese1" does solve this
So I see 3 workarounds to achieve "shaving" of characters.

#1)  quick & dirty
SELECT * FROM erp.Teste2 WHERE 
$TRANSLATE(firstname,'áéíóúÁÉÍÓÚçÇâêîôûÂÊÎÔÛ','aeiouAEIOUcCaeiouAEIOU') like 'fabio'


#2) more  elegant and also for other columns - create a SqlProcedure

ClassMethod shave(par) as %String [SqlProc, SqlName = "shave" ] 
{  quit $TRANSLATE(par,"áéíóúÁÉÍÓÚçÇâêîôûÂÊÎÔÛ","'aeiouAEIOUcCaeiouAEIOU") }


applied as 
SELECT * FROM erp.Teste2 WHERE erp.shave(firstname) like 'fabio'

#3) calculated property in your table - to be available also in index
Property firstshaved as %String [Calculated,SqlComputed,
SqlComputeCode = {set {*}=$TRANSLATE(firstname,"áéíóúÁÉÍÓÚçÇâêîôûÂÊÎÔÛ","aeiouAEIOUcCaeiouAEIOU")} ];

applied as 
SELECT * FROM erp.Teste2 WHERE firstshave like 'fabio'

#1) check that you run a Unicode installation. The U is important

#2) check the default language of your installation in SMP > ptbw and load it if required
http://localhost:52773/csp/sys/mgr/%25CSP.UI.Portal.NLS.zen 

#3) check the default of your database to see if your collation fits.
search for portuguese (?)

#4) any external commection should only use UTF-8

using SQL you can compare the last change between definition and compilation of classes
a negative difference shows where recompilation is required.
I used Posix-Timeformat for an easier compare

SELECT 
def.ID, cmp.TimeChanged compiled,  def.TimeChanged defined, 
to_char($piece(cmp.TimeChanged,',',1),'J')-to_char($piece(def.TimeChanged,',',1),'J') diff
FROM %Dictionary.ClassDefinition def
left outer join %Dictionary.CompiledClass cmp
on def.ID=cmp.ID
where NOT def.name %startswith '%'
order by 4

This list can be grouped into 3.5 categories:

  • Almost  Runtime changes

Only the last 2 are critical for successful mirror failover and require dynamic handling
and the last requires also non-stop monitoring as it is not directly triggered by SysAdmin.

2 remarks:

  • mapping your class to pseudo_namespace %ALL makes it available to all other namespaces except %SYS
  • to keep your options for a bitmap valid you may take the approach shown in my article of the Adopted Bitmap    The default of a storage global is ^Pck.ClassnameD .. and so on. But it can also be  ^Pck.ClassnameD(%InterfaceName,$namespace)  and the integer ID follows as you need. You just have to take care that %InterfaceName has some useful content.  Which shouldn't be a problem. I used %name to bypass all issues with ProcedureBlock.