DateTime Format: yyyyy
using System; using System.Globalization; public class Example { public static void Main() { DateTime date1 = new DateTime(1, 12, 1); DateTime date2 = new DateTime(2010, 1, 1); Console.WriteLine(date1.ToString("%y")); // Displays 1 Console.WriteLine(date1.ToString("yy")); // Displays 01 Console.WriteLine(date1.ToString("yyy")); // Displays 001 Console.WriteLine(date1.ToString("yyyy")); // Displays 0001 Console.WriteLine(date1.ToString("yyyyy")); // Displays 00001 Console.WriteLine(date2.ToString("%y")); // Displays 10 Console.WriteLine(date2.ToString("yy")); // Displays 10 Console.WriteLine(date2.ToString("yyy")); // Displays 2010 Console.WriteLine(date2.ToString("yyyy")); // Displays 2010 Console.WriteLine(date2.ToString("yyyyy")); // Displays 02010 } }