|
web
newsgroups
|
|||||||||||||||||||||||
|
|||||||||||||||||||||||
Entering dates in bound fields(not the time) in the DateTime field. I have a text field that is bound to a DateTime field in SQL. When I run the program, the field initially comes up blank for new records. I enter a date (like "03/14/06") and save the record. When I retrieve the record and display it again, the field shows "03/14/06 12:00:00 AM". Now, that's annoying (and I would like to not display the time) but I could live with it, if I had to. The problem is, if I leave the entry like that and save the record, I get an error message about my date field being too long for the field size. What?!?!?!? I let the database populate the field, I didn't change it, and now it says it's not good to put back in the database? How do I save a DateTime field properly into SQL Server 2005? That's the most important question. The secondary question is, how do I get a bound field to only show the Date portion of the database data? Dave,
What you ask about the database is impossible. The SQL server has two DateTime fields. One is the DateTime and the other the SmallDateTime. They both exist from different calculated ticks. The fist start at 1-1-1853 (when the British Empire started the Gregorian Calendar) and the other at 1900. To use from those date the parts, you can seperate parts using he datetime methods. By instance only the date portion of today is Now.Date To use in a control the date as a string, you can use the IFormatProvider, see for that this page. http://msdn.microsoft.com/library/default.asp?url=/library/en-us/cpref/html/frlrfsystemglobalizationdatetimeformatinfoclasstopic.asp That can be by instance by using the binding events or by using column styles. I hope this helps, Cor |
|||||||||||||||||||||||