I'm curious: What was the point of the cursor-like WHILE and incrementing the ID by 3? Just Obfuscation? Why didn't you just write the query as:
SELECT ID AS 'Select number', DATETIMEFROMPARTS ([Year],M,D,H,Mi,S,Ms) AS 'Datetime'
,CAST(S AS CHAR(2)) + ':' + CAST(Ms AS CHAR(3)) AS 'Original seconds input'