I tried to use the cypher below to convert datetime string into datetime format, which resulted only 1 batch failed but the rest completed successfully.
Maybe some n.devicetime are not strings?
You can try executing match (p:POSITION) return distinct apoc.meta.type(p.devicetime) to retrieve all distinct types.
Anyway, can you try with this query (in this way I filter only position with apoc.meta.type = 'string'):
CALL apoc.periodic.iterate(
"match(p:POSITION) where apoc.meta.type(p.devicetime) = 'STRING' return p",
"with p set p.devicetime = datetime({epochmillis: apoc.date.parse(p.devicetime, 'ms', 'yyyy-MM-dd HH:MM:ss')})",
{batchSize:100000,parallel:true});