public static void Main()
DateTime d1 = new DateTime(1974, 7, 10, 7, 10, 24);
Console.WriteLine("Day:{0}", d1.Day);
Console.WriteLine("Month:{0}", d1.Month);
Console.WriteLine("Year:{0}", d1.Year);
Console.WriteLine("Hour:{0}", d1.Hour);
Console.WriteLine("Minute:{0}", d1.Minute);
Console.WriteLine("Second:{0}", d1.Second);
Console.WriteLine("Day of Week:{0}", d1.DayOfWeek);
Console.WriteLine("Day of Year: {0}", d1.DayOfYear);
DateTime Day = DateTime.Now;
TimeSpan t = new System.TimeSpan(2, 0, 0, 0);
DateTime aDay = Day.Add(t);
DateTime a = Day.Subtract(t);
Console.WriteLine("{0:dddd}", aDay);
Console.WriteLine("{0:dddd}", a);
DateTime DateOfFirst = new DateTime(2021, 10, 22);
int result1 = DateTime.Compare(DateOfFirst, Day);
Console.WriteLine("Date of First is earlier");
Console.WriteLine("Both dates are same");
Console.WriteLine("Date of First is later");
DateTime Date = new DateTime(2020, 02, 25);
string[] f = Date.GetDateTimeFormats();
foreach (string format in f)
Console.WriteLine(format);
DateTime FormatOfDate = new DateTime(2020, 02, 25);
Console.WriteLine("----------------");
Console.WriteLine("d Formats");
Console.WriteLine("----------------");
string[] DateFormat = FormatOfDate.GetDateTimeFormats('d');
foreach (string format in DateFormat)
Console.WriteLine(format);
Console.WriteLine("----------------");
Console.WriteLine("D Formats");
Console.WriteLine("----------------");
DateFormat = FormatOfDate.GetDateTimeFormats('D');
foreach (string format in DateFormat)
Console.WriteLine(format);
Console.WriteLine("----------------");
Console.WriteLine("f Formats");
Console.WriteLine("----------------");
DateFormat = FormatOfDate.GetDateTimeFormats('f');
foreach (string format in DateFormat)
Console.WriteLine(format);
Console.WriteLine("----------------");
Console.WriteLine("F Formats");
Console.WriteLine("----------------");
DateFormat = FormatOfDate.GetDateTimeFormats('F');
foreach (string format in DateFormat)
Console.WriteLine(format);