Date Format

  • Thread starter Thread starter Guest
  • Start date Start date
G

Guest

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...
 
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-

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
 
Back
Top