vijay rags

vijay rags

  • NA
  • 68
  • 163.4k

How to handle negative TimeSpan in silverlight

Dec 23 2011 12:15 AM
Hi,

    I have two textboxes. One is the Start time and other is the end time. I need to check whether end time is greater than start time. I tried with Time Span but  i need to check for Hours, Minutes, Second. If it returns with "(-)" then i need to validate. How to do that. Please find the following code.


.cs
====

  DateTime dtStartTime = new DateTime();
                        DateTime dtEndTime = new DateTime();
                        TimeSpan dtDiff = new TimeSpan();
                     
                        dtStartTime = Convert.ToDateTime(txtMonStarttime.Text.Trim());
                        dtEndTime = Convert.ToDateTime(txtMonEndtime.Text.Trim());
                        dtDiff = dtEndTime - dtStartTime;

Here if the dtDiff returns values with negative then i need to check and validate it. Please help.


Thanks,
Vijay

Answers (2)