[dba-SQLServer] formatting smalldatetime textbox (somewhat OT)

Ron Allen chizotz at mchsi.com
Thu Jun 29 14:57:54 CDT 2006


Sorry, I know this is a bit OT since I thing the meat of the problem is in C#, 
but...

I have a smalldatetime field bound to a textbox in a C# WinForms project.

The entire datetime displays in the textbox, i.e. 01/01/2007 12:00:00 AM

I just want to display 01/01/2007

I can use Convert(varchar, my_date, 101) in the selection for the dataset the 
control is bound to, but that -- apparently -- makes updating the date field 
impossible. Calling update on the data adapter updates all other fields, but 
not the date field.

I've tried manually altering the update SQL in the data adapter to convert the 
@my_date field back to smalldatetime, i.e. SET my_date = Convert
(smalldatetime, @my_date), but that does not work either.

There are several seemingly good solutions on the web, but I can't get them to 
work either, and several of them seem like overkill for something 
that "should" be fairly easy. Am I just having a bad day, or is this really 
that big of a deal? What am I missing?

Any assistance or pointers to assistance appreciated.

Ron





More information about the dba-SQLServer mailing list