Fog Creek Software
Discussion Board




Welcome! and rules

Joel on Software

Date Format

I am trying to display a date in a text box on a web page that is the result of a query from an MS Access database.  The data is returned in a long date and time format.  I only need the date and not the 12:00:00 AM.  Is there a way to get this date data without the time and without having to Substring() it out manually?  The crazy thing is that I store it in the Database as a short date.

Not a Guru
Wednesday, October 06, 2004

When you do a ToString() on the date, use a format specifier, e.g.

string justDate = myDateTime.ToString("d");

Look up the DateTime structure's ToString() method in the help to get the various format strings.

There are many standard ones, like "d", which depend on your locale, or you can use your own like:

string justDate = myDateTime.ToString("yyyy-mm-dd");

Nemesis
Wednesday, October 06, 2004

I just went thru the DateTime experience yesterday and I was blown away by how flexible it is. The 'Parse' method seems to work if you give it anything that even loosely resembles a DateTime. And the documentation is good.

NetFreak
Wednesday, October 06, 2004

hgfhfg

hgfh
Thursday, October 07, 2004

*  Recent Topics

*  Fog Creek Home