date format

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Claudia Fong

    #1

    date format



    Hi,

    I use the following code to get the date from my db. The format is
    5/21/2005, but using the code below it will display: 5/21/2005
    12:00:00 AM

    label3.Text = Convert.ToStrin g(objReader["ADD_DATE"]);

    Is there a way so I can get only the date 5/21/2005 instead of the whole
    DATE/TIME??

    Can someone help me with this?


    Cheers!

    Claudi

    *** Sent via Developersdex http://www.developersdex.com ***
  • Steve Goodyear

    #2
    RE: date format

    Hi Claudia,

    You can use the GetDateTime method of the DataReader and then call the
    ToString method of the DateTime object with a formatting arguement:

    // assume the date column is the first at the index of zero
    label3.Text = objReader.GetDa teTime(0).ToStr ing("d");

    Cheers,
    Steve Goodyear

    Comment

    Working...