Date Format

Discussion in 'ASP .Net' started by =?Utf-8?B?RXJpY2E=?=, Jul 3, 2007.

  1. I am displaying a date field (not a datetime field) in a repeater. For some
    reason it is automatically inserting a default time (12:00:00AM) along with
    the date. I don't want to display this time. I've checked my database and
    it's not coming from there. Does anyone have an idea of what I can do to get
    the time out of there. Thanks. FYI...
     
    =?Utf-8?B?RXJpY2E=?=, Jul 3, 2007
    #1
    1. Advertising

  2. DateTime and Date are essentially the same. Use the ToString method, with
    the string format "d" to get a short DateTime format (mm/dd/yyyy).

    --
    HTH,

    Kevin Spencer
    Microsoft MVP

    Printing Components, Email Components,
    FTP Client Classes, Enhanced Data Controls, much more.
    DSI PrintManager, Miradyne Component Libraries:
    http://www.miradyne.net

    "Erica" <> wrote in message
    news:...
    >I am displaying a date field (not a datetime field) in a repeater. For some
    > reason it is automatically inserting a default time (12:00:00AM) along
    > with
    > the date. I don't want to display this time. I've checked my database and
    > it's not coming from there. Does anyone have an idea of what I can do to
    > get
    > the time out of there. Thanks. FYI...
     
    Kevin Spencer, Jul 3, 2007
    #2
    1. Advertising

  3. Erica-

    The easiest way to cut it out is to use String.Format to customize the format
    of the output. A short date is {0:d}.

    string justTheDate = String.Format("{0:d}", DateTime.Now);

    Would return "7/3/2007".

    Note, as above, this is culture dependent...

    For more information, check out the MSDN article at:

    https://msdn2.microsoft.com/en-us/library/fht0f5be.aspx

    HTH.

    -dl

    --
    David R. Longnecker
    http://blog.tiredstudent.com

    > I am displaying a date field (not a datetime field) in a repeater. For
    > some reason it is automatically inserting a default time (12:00:00AM)
    > along with the date. I don't want to display this time. I've checked
    > my database and it's not coming from there. Does anyone have an idea
    > of what I can do to get the time out of there. Thanks. FYI...
    >
     
    David R. Longnecker, Jul 3, 2007
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Brian Candy
    Replies:
    2
    Views:
    1,172
    Janaka
    Feb 18, 2004
  2. DC
    Replies:
    5
    Views:
    3,009
    Brendan Reynolds
    Jul 1, 2005
  3. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,278
    Michael Borgwardt
    May 30, 2004
  4. Chu
    Replies:
    3
    Views:
    4,194
    Shawn
    Aug 15, 2006
  5. Josh Sharpe
    Replies:
    1
    Views:
    212
    Brian Candler
    Sep 21, 2010
Loading...

Share This Page