SELECT
  N1COMP AS n1comp,
  N1CCYY AS n1ccyy,
  N1FSPP AS n1fspp,
  N1FSYY AS n1fsyy,
  N1FSYP AS n1fsyp,
  CASE WHEN N1SD01 IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE N1SD01 END AS n1sd01,
  CASE WHEN N1ED01 IN (DATE('0001-01-01'), DATE('9999-12-31')) THEN NULL ELSE N1ED01 END AS n1ed01
FROM LGDAT.GLDATREF
