FUNCTION "FC_DateAsString" : String
{ S7_Optimized_Access := 'TRUE' }
VERSION : 0.1
   VAR_TEMP 
      tInt : Int;
      tDTL {InstructionName := 'DTL'; LibVersion := '1.0'} : DTL;
      sTmp : String[5];
   END_VAR


BEGIN
	// Format: '21-05-12'
	
	#tInt := RD_LOC_T(#tDTL);
	
	#sTmp := UINT_TO_STRING(#tDTL.YEAR);
	#FC_DateAsString[1] := #sTmp[4];
	#FC_DateAsString[2] := #sTmp[5];
	#FC_DateAsString[3] := '-';
	#sTmp := USINT_TO_STRING(#tDTL.MONTH);
	IF #tDTL.MONTH <= 9 THEN
	    #FC_DateAsString[4] := '0';
	    #FC_DateAsString[5] := #sTmp[2];
	ELSE
	    #FC_DateAsString[4] := #sTmp[2];
	    #FC_DateAsString[5] := #sTmp[3];
	END_IF;
	#FC_DateAsString[6] := '-';
	#sTmp := USINT_TO_STRING(#tDTL.DAY);
	IF #tDTL.DAY <= 9 THEN
	    #FC_DateAsString[7] := '0';
	    #FC_DateAsString[8] := #sTmp[2];
	ELSE
	    #FC_DateAsString[7] := #sTmp[2];
	    #FC_DateAsString[8] := #sTmp[3];
	END_IF;
END_FUNCTION

