Textbox MSSQL Date Only

y2kmental

Member
Joined
Dec 30, 2005
Messages
9
Programming Experience
Beginner
Hello, i am fairly new to programing and I am taking a class in school on .Net, its not such a great class.


I am in the process of making a program that access an MSSQL database.

I have a date of birth textbox that is bound to the same on the db using databindings.Add("text")...

I type a date into the text box and it shows a date and also time (12:00:00 AM), which is usless to me.

Is there any easy way or proerty to set to disable the time?


This is also gonna be required in the opposite order (just time not date)


Thanks for your help.

-Mark
 
If you are using the MaskedTextBox in VS05, then you can set the mask to Short date.
 
im using vs.net 2003, is there a maskedtextbox in this version? i always seem one step behind with the software. lol

is there any code our there that i can make a user defined control out of?
 
No, maskedtextbox didn't exist in VS03.
You said "you type a date into a textbox and it shows time too"...
How come? What coding from you makes this happen?
 
I try this and get no time added when I write date. Maybe we don't have the same code...
Would it not be better to bind to a DateTimePicker control ?
 
Ugh....
How about a modification to the SQL?

VB.NET:
CONVERT(varchar(10), _yourDate_field_name_here_, 101)
Just plug that into your SELECT, replacing your field name as appropriate, and giving it an alias (ie "AS _some_Filed_name_")..... it will format it as mm/dd/yyyy.

-tg
 
JohnH said:
I try this and get no time added when I write date. Maybe we don't have the same code...
Would it not be better to bind to a DateTimePicker control ?

Hey it worked, i didnt even think of doing that


thank you johnH and techgnome




i was almost afraid it wouldnt work becuse im using databingings in code to "text"

dtpCertExpr.DataBindings.Add("text", DsMembers1, "TBLMEMBERS.CertExpr")

The next thing ill have to tackle is accessing a photo from the db, but ill start another thread for that, thanks
 
Back
Top