Showing posts with label C#. Show all posts
Showing posts with label C#. Show all posts

Wednesday, 9 July 2014

Convert String to Date Time and Subtract to Current Date Time and store in Integer Variable In C#

  Convert String to Date Time and Subtract to Current Date Time and store in Integer Variable In C# 



string str = dr[0].ToString();
                DateTime OLDDATE = DateTime.Now.AddHours(5.5);
                DateTime NEWDATE = DateTime.ParseExact(str, "dd/MM/yyyy", null);
                TimeSpan span = NEWDATE.Subtract(OLDDATE);
                int day = Convert.ToInt16(span.TotalDays);