Subtract 2 columns

Subtract 2 columns

zandotczandotc Posts: 2Questions: 1Answers: 0
edited January 2017 in Free community support

How to subtract 2 columns?
http://imgur.com/a/wMOpc

thx

Answers

  • tangerinetangerine Posts: 3,365Questions: 39Answers: 395

    If your data comes from a database, have your database query deal with it.

  • zandotczandotc Posts: 2Questions: 1Answers: 0

    There is no third date column. Shows only in client-side. The value of data1 subtracted from data2 generate data3

    Data1 = 2017-01-05 15:10:20
    Data2= 2017-01-06 15:10:20
    Data3 = Data2 - Data1

  • kthorngrenkthorngren Posts: 21,559Questions: 26Answers: 4,994

    What type of data will data3 be, ie, is it the time difference or something else?

    You can do as Tangerine suggests and have your backend app perform the calculation and return the result as data3 along with the query result. Or you may be able to use column.render in the third column to perform the calculation.
    https://datatables.net/reference/option/columns.render

    Kevin

  • allanallan Posts: 63,836Questions: 1Answers: 10,518 Site admin

    Yes, on the client-side, using a data renderer is the way to do this. You may also want to use something like MomentJS to help make the date / time handling easier.

    Allan

This discussion has been closed.