if my computer datetime format as yy/mm/dd or mm/dd/yyyy or regardless formation
Datetime date1 = ... /// assume date1 is date1 < date2 and date1 < date3
DateTime date2 = DateTime.Parse(DateTime.Now.ToString("dd-MM-yyyy")) ;
DateTime date3 = DateTime.Now.Date;
DateTime.Compare(date1 ,date2); and DateTime.Compare(date1 ,date3);
Not sure why are you doing
To answer your question, both
date3 will become different depending on your computer (or the device that is running this code) localization.
date1 is always earlier you can do
TimeSpan diff = date3 - date1; which will give you
TimeSpan object. Then you can
diff.Days to get the number of days difference.
date3 will only have date in there. The time will be set to 12:00 midnight. See here.