WITH A AS(
SELECT 
'20'+SUBSTRING(HDATUM,5,2)+SUBSTRING(HDATUM,3,2)+SUBSTRING(HDATUM,1,2) SVE_DATUM,
HDATUM FIN_DATUM
FROM 
LD0P0C11 
WHERE HTYP IN (391,392)
AND LEN(HDATUM)=6)
UPDATE A SET FIN_DATUM=SVE_DATUM
;

UPDATE LD0P0C11 SET UPDDAT=CASE 
	 WHEN LEN(UPDDAT)=6 AND SUBSTRING(UPDDAT,1,2)<=21 THEN '20'+UPDDAT
	 WHEN LEN(UPDDAT)=6 AND SUBSTRING(UPDDAT,1,2)>21 THEN '19'+UPDDAT
	END
WHERE LEN(UPDDAT)=6
;