Datetime Question

  • Thread starter Thread starter Luke Davis
  • Start date Start date
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
 
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");
 
Back
Top