Hi,
What are you doing? are you using a SP or a query?
These are the steps:
1- Make sure the text is correct ! , why not use a Calendar instead of a
Textbox?
2- Convert the text to DateTime :
DateTime.ParseExact( textbox.Text, "dd/MM/yyyy" ,
DateTimeFormatInfo.InvariantInfo);
3- If you are using a sp, it's easy :
command.Parameters.Add("@assigneddate", SqlDbType.DateTime).Value =
DateTime.ParseExact( textbox.Text, "dd/MM/yyyy" ,
DateTimeFormatInfo.InvariantInfo);
4- If you are using a query then yo ushould use a parameterize query:
string selectSQL = "SELECT * FROM table1 WHERE tehdate= ? ";
SqlCommand selectCMD = new SqlCommand(selectSQL, theconn);
selectCMD.Parameters.Add("@thedate", SqlDbType.NVarChar, 15).Value =
DateTime.ParseExact( textbox.Text, "dd/MM/yyyy" ,
DateTimeFormatInfo.InvariantInfo);
cheers,
--
Ignacio Machin,
ignacio.machin AT dot.state.fl.us
Florida Department Of Transportation
"Assimalyst" <c_******@hotmail.com> wrote in message
news:11*********************@g49g2000cwa.googlegro ups.com...
Hi i have a value entered into an asp text box,
procedureDateTxtBx.Text, thet has the format dd/MM/yyyy. I need to
convert this into a format recognisable by SQL server in order to
properly query the database.
I've tried a few DateTime.Parse methods but can't get any to work.
The format of these values in the database is
yyyy-MM-dd hh:mm:ss.000
Thanks