sum field of datatable with condition RRS feed

  • Question

  • Hi folks,

    I need to sum the value of a field with a condition..

    // Declare an object variable.

    object sumObject; 

    sumObject = _dsSalesHistory.Tables[0].Compute("Sum(lineWeight)", "Convert.ToInt32(substring(despatchDate, 0, 4)) = '" + y + "'" );

    Except despatchDate is a DateTime type and I cant perform substring on it. I just need to compare the year() of the date with y variable.

    Any ideas ?


    Thursday, February 28, 2019 11:08 AM