Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 727355
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 14, 20262026-05-14T06:33:30+00:00 2026-05-14T06:33:30+00:00

I have a form that allows users to enter a date of birth: ie:

  • 0

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

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-14T06:33:30+00:00Added an answer on May 14, 2026 at 6:33 am

    Your best option is to only accept 4-digit years, but the RTL does support changing the way 2-digit days are handled. The TwoDigitYearCenturyWindow global variable, or the TFormatSettings.TwoDigitYearCenturyWindow field control this. The RTL documentation says:

    TwoDigitYearCenturyWindow – Determines what century is added to two digit years when converting
    string dates to numeric dates. This value is subtracted from the current year before extracting the century. This can be used to extend the lifetime of existing applications that are inextricably tied to 2 digit year data entry. The best solution to Year 2000 (Y2k) issues is not to accept 2 digit years at all – require 4 digit years in data entry to eliminate century ambiguities.

    Examples:

    Current TwoDigitCenturyWindow  Century  StrToDate() of:
    Year    Value                  Pivot    '01/01/03' '01/01/68' '01/01/50'
    -------------------------------------------------------------------------
    1998    0                      1900     1903       1968       1950
    2002    0                      2000     2003       2068       2050
    1998    50 (default)           1948     2003       1968       1950
    2002    50 (default)           1952     2003       1968       2050
    2020    50 (default)           1970     2003       2068       2050
    

    So if you’re only parsing birthdays, you should be able to set TwoDigitCenturyWindow to 99 or 100 and it will always give older dates.

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a form that allows a user to enter the length of an
I have a form that allows users to enter a date when they are
I have a TextBox in a Windows Form that allows a user to enter
I have a form that allows me to enter a user into my database.
I have a textarea in a form that allows users to enter a list
I have a query builder form that allows a user to enter values into
I have a simple HTML Form that allows the user to enter some text
I have a form that allows the user to enter a weight, in either
I have a safecracker form that allows users to enter title, url_title body content.
I have a form that allows a user to enter their username and password

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.