Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
75
Date year reverts back to last century
posted

I’m having an issue where users will enter 07/16/30 into the field and the value gets saved as 07/16/1930 instead of 07/16/2030. If 07/16/29 is entered it gets saved as 07/16/2029.

I currently have my Mask Input set to "mm/dd/yyyy" and my Format String set to "MM/dd/yy"

Is there some default value that gets set for what year to choose when only the last 2 characters of the year have been entered?

Parents
No Data
Reply
  • 469350
    Offline posted

    Hi,

    This is not really related to the DateTimeEditor, this is the behavior of Microsoft Windows. If you only use 2 digits for the year, Microsoft arbitrarily designates the number 30 as the cutoff point for the century.

    You can demonstrate this without using any Infragistics controls very simply like so:


                string s = "07/16/30";
                DateTime dt = DateTime.Parse(s);

                Debug.WriteLine(dt);

    I recommend that you use a 4-digit mask for the year so that there is no ambiguity.

Children