want to pass date with Time part

dhj

Regular
Joined
Sep 18, 2003
Messages
82
Location
Sri Lanka
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
 
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
 
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
 
Back
Top