Converting date from textbox to DateTime
I have a date in a textbox that came from a popup Calendar control. Now I would like to take the date i returned to this textbox and update it to an SQL Server, but the problem is that the value have to be DateTime and not text.
Can anyone tell me how to do this please.
Thanks.
Re: Converting date from textbox to DateTime
VB Code:
Dim dteDate as date
dteDate = ctype(textbox1.text, date)
If you want to check if it is a date first, you can use the IsDate() function.
Re: Converting date from textbox to DateTime
System.Convert
or construct a new datetime from the string date time
Re: Converting date from textbox to DateTime
Thanks to the both of you for the replies. I tried both already, but it was really my own stupidity that prevented it from working. The field I was converting was disabled and so the value being converted was '' and thus wouldnt work.
Thanks again guys.