Your Privacy Matters: We use our own and third-party cookies to improve your experience on our website. By continuing to use the website we understand that you accept their use. Cookie Policy
45
Need Helpp...
posted

How to calculate time duration using two webDateChoosers (Ex:-From Date & To Date - Need to calculate Number of days)

And how to validate From Date with System date??

Please give me the solutions ASAP..

Thank You.

 

Parents
No Data
Reply
  • 3255
    Suggested Answer
    posted

    Hello,

    I have created a sample for you on how to calculate number of days.  Please  also refer to the below lines of code. Attached is the sample. 

       16         DateTime startDate = DateTime.MinValue;

       17         DateTime endDate = DateTime.MinValue; ;

       18         DateTime.TryParse(WDCStartDate.Value.ToString(), out startDate);

       19         DateTime.TryParse(WDCEndDate.Value.ToString(),out endDate);

       20 

       21         if (startDate != DateTime.MinValue && endDate != DateTime.MinValue)

       22         {

       23             System.TimeSpan diff1 = endDate.Subtract(startDate);

       24             int days = diff1.Days;

       25             Label1.Text = "Number of Days = " + days;

       26         }

    WebDateChooser.zip
Children
No Data