Handle negative time spans

前端 未结 9 543
不知归路
不知归路 2020-12-30 18:50

In my output of a grid, I calculate a TimeSpan and take its TotalHours. e.g.

(Eval(\"WorkedHours\") - Eval(\"BadgedHours\")).TotalH         


        
相关标签:
9条回答
  • 2020-12-30 19:41

    its working .try this

    mytimespam.Negate();

    0 讨论(0)
  • 2020-12-30 19:45

    I checked to every where.But i didnt get a correct answer that why i used this way to finish

    TimeSpan diff = actualout.Subtract(actualin);
     string a =(diff.ToString()).ToString();
    if(a.Contains("-"))
     {        
     diff = new TimeSpan(0,0,0,0);
    }
    
    0 讨论(0)
  • 2020-12-30 19:46

    There is a Negate method in the TimeSpan class.

    Link to the MSDN documentation: TimeSpan.Negate Method()

    0 讨论(0)
提交回复
热议问题