Short Date Format bug 2050 changes to 1950

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)
      m_dataTable.Rows.Add(values)
      DateTimePicker1.DataBindings.Add("Text", m_dataTable, "date1")
    End If
  End Sub
LVL 4
NicoLaanAsked:
Who is Participating?
I wear a lot of hats...

"The solutions and answers provided on Experts Exchange have been extremely helpful to me over the last few years. I wear a lot of hats - Developer, Database Administrator, Help Desk, etc., so I know a lot of things but not a lot about one thing. Experts Exchange gives me answers from people who do know a lot about one thing, in a easy to use platform." -Todd S.

NicoLaanAuthor Commented:
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.
0
GranModCommented:
Closed, 500 points refunded.
GranMod
The Experts Exchange
Community Support Moderator of all Ages
0

Experts Exchange Solution brought to you by

Your issues matter to us.

Facing a tech roadblock? Get the help and guidance you need from experienced professionals who care. Ask your question anytime, anywhere, with no hassle.

Start your 7-day free trial
It's more than this solution.Get answers and train to solve all your tech problems - anytime, anywhere.Try it for free Edge Out The Competitionfor your dream job with proven skills and certifications.Get started today Stand Outas the employee with proven skills.Start learning today for free Move Your Career Forwardwith certification training in the latest technologies.Start your trial today
Visual Basic.NET

From novice to tech pro — start learning today.