Date Formatting Problem

  • Thread starter Thread starter Thomas Beyerlein
  • Start date Start date
T

Thomas Beyerlein

I am binding dates to a textbox, the date is stored in SQL in a datetime
field. When it gets bound it turns it into a long date (Sunday, Dec. 25
2005), in SQL when viewing the table it views as a shortdate. When
inserted to SQL the datetimepicker format for the date is short. I have
not had a problem with the formatting of a date to a textbox before, but
this time I am using the CurrencyManager to navigate though several
records. This is the code it am using to bind it to the textbox:

txtArchiveDate.DataBindings.Add("Text", myDV, "Archive_Date")


Any suggestions on how to fix this date formatting problem would be
helpful.

Thanks
Tom
 
Look at creating a Binding object and then adding that to your
Control's DataBindings

'something like this should work
Dim b As New Binding("Text", myDV, "Archive_Date")
'then either
AddHandler b.Format, AddressOf ShortDateToLongDate
'or
b.FormatString = "{0:d}"
txtArchiveDate.DataBindings.Add(b)
 
This doesn’t work do to the fact that it is a binding and not a string.
Any other ideas
I even tried Changing the SQL to a nvarchar and it still gives me a long
date
 
Back
Top