PDA

View Full Version : how to convert String into Date only?


yawowcom001
05-15-2004, 06:22 AM
DateTime myTime = new DateTime();
myTime = Convert.ToDateTime(Txt_Day.Text);
int orderID = myOrder.PlaceOrder(lb_CustomerID.Text, cartID, myTime, Txt_Shi........);

When insert the date into database, the datetime doesn't go through. Example: In Sql database DateTime"[8]", when I input "28/04/2004", myTime = 28/04/2004 00:00:00, not just 28/04/2004. Please help?

bruce
05-16-2004, 12:32 PM
do you get any error?

quote:Originally posted by yawowcom001

DateTime myTime = new DateTime();
myTime = Convert.ToDateTime(Txt_Day.Text);
int orderID = myOrder.PlaceOrder(lb_CustomerID.Text, cartID, [b]myTime, Txt_Shi........);

When insert the date into database, the datetime doesn't go through. Example: In Sql database DateTime"[8]", when I input "28/04/2004", myTime = 28/04/2004 00:00:00, not just 28/04/2004. Please help?
</blockquote id="quote"></font id="quote">

yzarc
05-18-2004, 06:05 AM
I think what you are referring to is that inserting a date into the DB into a date field results in date and time being inserted.

That is because a date is stored as so many time increments since 01/01/0001 or something like that. I believe that the increment is seconds. Anyway a date is stored as so many seconds from 01/01/0001 which by it's very nature includes a date and time. Even though it is stored with time, you can always format as short date when displaying.

Greg
quote:Originally posted by bruce

do you get any error?

[b]quote:Originally posted by yawowcom001

DateTime myTime = new DateTime();
myTime = Convert.ToDateTime(Txt_Day.Text);
int orderID = myOrder.PlaceOrder(lb_CustomerID.Text, cartID, [b]myTime, Txt_Shi........);

When insert the date into database, the datetime doesn't go through. Example: In Sql database DateTime"[8]", when I input "28/04/2004", myTime = 28/04/2004 00:00:00, not just 28/04/2004. Please help?
</blockquote id="quote"></font id="quote">
</blockquote id="quote"></font id="quote">

Greg Kelley