how to convert String into Date only?

Discussion in 'ASP.NET / ASP.NET Core' started by yawowcom001, May 15, 2004.

Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.
  1. 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?
     
  2. Bruce

    Bruce DiscountASP.NET Staff

    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, 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">
     
  3. 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?

    quote:Originally posted by yawowcom001

    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?
    </blockquote id="quote"></font id="quote">
    </blockquote id="quote"></font id="quote">

    Greg Kelley
     
Thread Status:
Threads that have been inactive for 5 years or longer are closed to further replies. Please start a new thread.

Share This Page