I have a few overloads for YY conversion, mostly used to convert from imported text files:
function GetYYFromDate(const aDate: TDate): integer; overload;
begin
// 01/01/2019 -> 19
Result := FormatDateTime('yy', aDate).ToInteger;
end;
function GetYYFromDate(const aDate: TDateTime): integer; overload;
begin
// 01/01/2019 01:01:01 -> 19
Result := FormatDateTime('yy', aDate).ToInteger;
end;
function GetYYFromDate(const aDate: string): integer; overload;
begin
// '01/01/2019' -> 19
Result := Copy(aDate, Length(aDate) - 2, Length(aDate)).ToInteger;
end;
function GetYYFromYear(const aYear: string): integer; overload;
begin
// '2019' -> 19
Result := Copy(aYear, Length(aYear) - 2, Length(aYear)).ToInteger;
end;
function GetYYFromYear(const aYear: integer): integer; overload;
begin
// 2019 -> 19
Result := aYear mod 100;
end;