Delphi DateTimeFormat returning wrong year
- by Leslie
I have a form that allows users to enter a date of birth:
ie: 4/16/40
Then when the user processes the form there's a function that checks it's length, adds leading zeros, parses the date and then uses FormatDateTime to just return the year of birth:
strTemp := strPostedByDOB;
If Length(strTemp) = 5
then strTemp = '0' + strTemp;
if Length(strTemp) = 6
then begin
strTemp := Copy(strTemp, 1 ,2) + '/' + copy(strTemp, 3, 2) + '/' + Copy(strTemp, 5, 2);
strTemp := FormatDateTime('YYYY', StrToDate(strTemp));
end
else strTemp := EmptyStr;
using this code the strTemp is calculated as 2040 instead of 1940. Can anyone help me figure out how to make it show 1940 in strTemp? Do I have to change the form to accept a 4 digit year?
Thanks,
Leslie