Short Date Format bug 2050 changes to 1950

Posted on 2006-04-18
Last Modified: 2010-04-23
In the regional settings, the Short Date Format is set to d-M-yy. I assume any setting with 2 figures for the date will give this bug.
"When a 2 digit year is entered interpret it as a year" between 1930 and 2029.
So if I enter 50 it should see it as 1950. If I enter 20 it should see it as 2020.

I have a dateTimePicker control on my form with a 4 digit year setting.
I set it to custom yyyy-MM-dd to be exact.

When I enter 2050 and go to the next control it keeps 2050 as the year.

Now I bind the control using the code below.
Now when I enter 2050 and go to the next control it changes the date to 1950!!!

My actual code uses binding to a SQL-server datatable and gives the same bug.
But this is easier to reproduce.
Bug found in Windows 2000 and XP professional using VS 2005, .NET 2.0.

Does anyone know a solution to this bug, other then changing the regional settings or not using databinding of course.

  Private Sub Button1_Click(ByVal sender As System.Object, ByVal e As System.EventArgs) Handles Button1.Click
    Dim dt As DateTime = New DateTime()
    Dim values As Object() = {#11/18/1970#} ' any random date

    If m_dataTable Is Nothing Then
      m_dataTable = New DataTable
      m_dataTable.Columns.Add("date1", dt.GetType)
      DateTimePicker1.DataBindings.Add("Text", m_dataTable, "date1")
    End If
  End Sub
Question by:NicoLaan
    LVL 4

    Author Comment

    Solved the bug.
    Why didn't I see this before!!

    Changed binding from Text to Value
    DateTimePicker1.DataBindings.Add("Value", m_dataTable, "date1")

    Now it works.

    Accepted Solution

    Closed, 500 points refunded.
    The Experts Exchange
    Community Support Moderator of all Ages

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    What Should I Do With This Threat Intelligence?

    Are you wondering if you actually need threat intelligence? The answer is yes. We explain the basics for creating useful threat intelligence.

    A while ago, I was working on a Windows Forms application and I needed a special label control with reflection (glass) effect to show some titles in a stylish way. I've always enjoyed working with graphics, but it's never too clever to re-invent …
    Creating an analog clock UserControl seems fairly straight forward.  It is, after all, essentially just a circle with several lines in it!  Two common approaches for rendering an analog clock typically involve either manually calculating points with…
    This video is in connection to the article "The case of a missing mobile phone (". It will help one to understand clearly the steps to track a lost android phone.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    761 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    12 Experts available now in Live!

    Get 1:1 Help Now