formatting datetime data from a data reader field

Collapse
This topic is closed.
X
X
 
  • Time
  • Show
Clear All
new posts
  • Lauchlan M

    #1

    formatting datetime data from a data reader field

    Hi

    In an ASP.NET application, I am doing the following (dtrData is a data
    reader that has been loaded with data already):

    if (dtrData.Read() )
    {
    lblEDPresentati onTime.Text = (DateTime)
    dtrData["EDPresentation Time"].ToString();
    }

    Currently this is giving me values such as "24/07/2002 9:17:52 PM"
    displayed.

    What I want to do is get the date and the time bits and format them as I
    wish.

    I figure the best way to do this is to get the EDPresentationT ime field
    value into a system DateTime variable and then use formatting on that.

    What is the way to get the field value into a DateTime type?

    Thanks

    Lauchlan M


  • Stefan

    #2
    Re: formatting datetime data from a data reader field

    Use the IFormat provider to format your datatime as you wish

    "Lauchlan M" <LMackinnon@Hot mail.com> wrote in message
    news:%23i$JTUpd DHA.2560@TK2MSF TNGP10.phx.gbl. ..[color=blue]
    > Hi
    >
    > In an ASP.NET application, I am doing the following (dtrData is a data
    > reader that has been loaded with data already):
    >
    > if (dtrData.Read() )
    > {
    > lblEDPresentati onTime.Text = (DateTime)
    > dtrData["EDPresentation Time"].ToString();
    > }
    >
    > Currently this is giving me values such as "24/07/2002 9:17:52 PM"
    > displayed.
    >
    > What I want to do is get the date and the time bits and format them as I
    > wish.
    >
    > I figure the best way to do this is to get the EDPresentationT ime field
    > value into a system DateTime variable and then use formatting on that.
    >
    > What is the way to get the field value into a DateTime type?
    >
    > Thanks
    >
    > Lauchlan M
    >
    >[/color]


    Comment

    Working...