Date Format

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

Kevin Spencer

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
 
D

David R. Longnecker

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
 

Ask a Question

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

You'll need to choose a username for the site, which only take a couple of moments. After that, you can post your question and our members will help you out.

Ask a Question

Members online

Forum statistics

Threads
473,764
Messages
2,569,564
Members
45,039
Latest member
CasimiraVa

Latest Threads

Top