I have an application that uses the Date in this format: 200741 for April 1.
I need it to be like this: 20070401. Here is my code that generates the
date:
string sFileDate = DateTime.Now.Year.ToString() +
DateTime.Now.Month.ToString() + DateTime.Now.Day.ToString();
How can I get it to write the leading zero on months and days that are less
than 10?
DateTime.Now.ToString("yyyyMMdd")
Hope this helps

Signature
Chris Taylor
http://dotnetjunkies.com/weblog/chris.taylor
>I have an application that uses the Date in this format: 200741 for April
>1. I need it to be like this: 20070401. Here is my code that generates the
[quoted text clipped - 4 lines]
> How can I get it to write the leading zero on months and days that are
> less than 10?
William C. Clay - 26 Apr 2007 00:34 GMT
Too easy. Thank you.
> DateTime.Now.ToString("yyyyMMdd")
>
[quoted text clipped - 7 lines]
>> How can I get it to write the leading zero on months and days that are
>> less than 10?