dhj Posted February 10, 2004 Posted February 10, 2004 hi in my web application i have a textbox which contains a date i need to send this date to the database how i did that was like follows (In C#) DateTime StartDate; StartDate=DateTime.Parse(txtStartDate.Text).Date; my problem is this is passing '2/10/2004 12:00:00 AM' but i donot want to pass this whole thing bcos my sql storedprocedure doesn't work if i pass above whole thing. i need to pass one the '2/10/2004' part does any body have an idea thank you very much in advance Quote
fadi Posted February 10, 2004 Posted February 10, 2004 after ur code, u shoud put startdate = formatdatetime(StartDate,DateFormat.ShortDate) Quote
dhj Posted February 11, 2004 Author Posted February 11, 2004 hi fadi thx for replying but there's no function like formatfatetime in C# it is in vb.net can u help pls Quote
a_jam_sandwich Posted February 11, 2004 Posted February 11, 2004 Heres how to format dates in C# System.DateTime.Now.ToString("dd/MM/yyyy"); You can format on the ToString method. Using your method DateTime StartDate; StartDate = DateTime.Parse(textBox1.Text).Date; whatever = DateTime.ToString("dd/MM/yyyy") Andy Quote Code today gone tomorrow!
dhj Posted February 11, 2004 Author Posted February 11, 2004 hi a_jam_sandwich thx for replying but this is converting the date to string i want the type of the variable as datetime after formatting thx Quote
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.