2
Answers

How to handle negative TimeSpan in silverlight

vijay rags

vijay rags

12y
3.6k
1
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)