How to retrieve only the date without the time

Posted on 2009-02-09
Last Modified: 2012-05-06
I am reading a date from the database. It has the time appended to the date, because that is how it is stored in SQL server. The problem is that I only want the date portion of the string. Not the hour. How do I do this? Here is an example of the string returned.
2008-10-16 00:00:00.000
TextBox Lmcotangentreason = (TextBox)filterAlchoholMonitoring.FindControl("Lmcotangentreason");

            Lmcotangentreason.Text = Client.cotangent.DateOnProgram.Value.ToString();

Open in new window

Question by:brgdotnet
    LVL 14

    Accepted Solution

    How about this?
    ateTime dt = DateTime.Now;
    string sDate = dt.ToString("dd/MM/yyyy");
    using System.Globalization;
    DateTime dt = DateTime.Now;
    string sDate = dt.ToString("d", new CultureInfo("en-CA"))

    Open in new window

    LVL 2

    Author Closing Comment

    Awesome, thanks!

    Write Comment

    Please enter a first name

    Please enter a last name

    We will never share this with anyone.

    Featured Post

    Highfive Gives IT Their Time Back

    Highfive is so simple that setting up every meeting room takes just minutes and every employee will be able to start or join a call from any room with ease. Never be called into a meeting just to get it started again. This is how video conferencing should work!

    Suggested Solutions

    This article discusses the ASP.NET AJAX ModalPopupExtender control. In this article we will show how to use the ModalPopupExtender control, how to display/show/call the ASP.NET AJAX ModalPopupExtender control from javascript, how to show/display/cal…
    It was really hard time for me to get the understanding of Delegates in C#. I went through many websites and articles but I found them very clumsy. After going through those sites, I noted down the points in a easy way so here I am sharing that unde…
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    Access reports are powerful and flexible. Learn how to create a query and then a grouped report using the wizard. Modify the report design after the wizard is done to make it look better. There will be another video to explain how to put the final p…

    760 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now