Calculate no of remaining days or months from Date c#
  • Hello
    i want to calculate Number of days, months or years remaining in a specific date or time period.
    I  have a DATE column in database and lets say its value is 10-16-2015.. i want to calculate number of days remaining to reach 10-16-2015. i want to do this in c#

    Please tell me how can i do this..

  • 5 Comments sorted by
  • Vote Up0Vote Down WaqasWaqas
    172.00 Karma Accepted Answer
    you can simply apply minus operator between two dates for find different between both like this.

    double Days = (Convert.ToDateTime("2015-10-16") - DateTime.Now.Date).TotalDays;
                MessageBox.Show(Days + " Remaining"); 
  • how to get the Round of days Waqas
  • Hello @Akwin_lopez,

    what do you mean by Round of days? can you please give me example?.

    and request that kindly ask as new question don't further continue discussion on already resolved question except answers.
  • sorry & hence forth i never do like that and the example is
    if the remaining days 12.3336 means its shows like 12.3 that is more enough for me plz help me
  • double Days = (dateTimePicker1.Value - DateTime.Now.Date).TotalDays;
    int day =Convert.ToInt32(Days);
    MessageBox.Show(day + " Remaining");

Howdy, Stranger!

It looks like you're new here. If you want to get involved, or you want to Ask a new Question, Please Login or Create a new Account by Clicking below

Login with Facebook

Popular Posts of the Week

    Optimum Creative