Skip to content

DateTime formatting

Jagannatha Thripp

Asked Nov 21, 2006, 4:57 PM EST1 answer
Share
LinkedInX
Hello Everyone, I am trying to pass two dates to a stored procedure in SQL server. I only require the date protion of the input not the time, but I cannot seem to get the formatting to just mm/dd/yyyy the data is collected from two text boxes on a web form and is imput as string in the format mm/dd/yyyy. The SP is expecting datetime parameters. I have tried so many variations to this I am wondering if it can even be done???? DateTime FromDate = DateTime.ParseExact(tempdt, "mm/dd/yyyy", System.Globalization.CultureInfo.InvariantCulture); DateTime Todate = Convert.ToDateTime(ToDateLbl.Text); None of these work. All help grealy accepted.

1 Answer

Know the answer? Post it. Somebody with the same question will find it here.

  • 0
    Hi,

    DateTime dt = DateTime.Parse(dateString);
    string onlyDate = dt.ToString("mm/dd/yyyy");

    hope this may help you

    thanks and regards,
    kumar

    0