ellapt

T14.16.DaysDifference

Feb 3rd, 2013
50
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.64 KB | None | 0 0
  1. using System;
  2. using System.Globalization;
  3.  
  4. class DaysDifference
  5. {
  6. static void Main()
  7. {
  8. Console.WriteLine("Calculate number of days between two dates: day.month.year\n");
  9.  
  10. string date1 = "27.02.2006";
  11. string date2 = "3.03.2006";
  12.  
  13. DateTime date1Date = DateTime.ParseExact(date1, "d.MM.yyyy",
  14. CultureInfo.InvariantCulture);
  15. DateTime date2Date = DateTime.ParseExact(date2, "d.MM.yyyy",
  16. CultureInfo.InvariantCulture);
  17. Console.Write("The number of days between {0} and {1} is ", date1, date2);
  18. Console.WriteLine((date2Date - date1Date).TotalDays);
  19. }
  20. }
Advertisement
Add Comment
Please, Sign In to add comment