Datetime Question

L

Luke Davis

Is there a way to format the date into an YYYY:MM:DD format?

Right now January, for example, is equal to 1, instead of 01. Is there a
way, besides writing a long if/then, of formating all single digit dates to
prefix a 0?

So January 1, 2001 would look like 2001-01-01, not 2001-1-1.

Thanks,

--
Luke Davis, MCSE: Security
DEM Networks - Senior Systems Architect
7225 N First, Suite 105
Fresno, CA 93720
Office: 1 (559) 439-1000
Fax: 1 (866) 640-2041
www.demnetworks.com
 
T

Tom Porterfield

Luke said:
Is there a way to format the date into an YYYY:MM:DD format?

Right now January, for example, is equal to 1, instead of 01. Is there a
way, besides writing a long if/then, of formating all single digit dates to
prefix a 0?

So January 1, 2001 would look like 2001-01-01, not 2001-1-1.

string formattedDate = DateTime.Now.ToString("yyyy-MM-dd");
 

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

Similar Threads


Top