Calculation of time difference in formula

Options
Nick_779929
Nick_779929 Posts: 5
edited March 2021 in Questions

Hello Community,
I try to calculate in my data table to calculate with an script the time difference of two Date/Time-Stamps.
I want to realize it with the Action Apply Formula to Columns.
Thanks for help!

Tagged:

Best Answer

  • Sean_510793
    Sean_510793 Posts: 69 admin
    Answer ✓
    Options

    Hi Nick, I can’t test this myself but for the two lines, could you try changingfields[‘Startzeit’] to columns[‘Startziet’] and fields[‘Endezeit’] to columns[‘Endezeit’] respectively?

Answers

  • Sean_510793
    Sean_510793 Posts: 69 admin
    Options

    Did you want to put the time difference back into the table in another field? Or did you want to do something like filter on (date2 - date1) greater than 1 day?

  • Nick_779929
    Options

    Hey Sean,
    I want to insert the time in minutes in an existing field in my data table.
    Column 1 Column2 Column3
    Time/Date Time/Date Time difference in minutes

  • Nick_779929
    Options

    I wrote the following script, but the time in minutes will not written in the data table.
    var startzeit = new Date(fields['Startzeit']);
    var endzeit = new Date (fields['Endezeit']);
    var zeit;
    zeit = Math.abs(startzeit - endzeit);
    zeit = startzeit.getDate() - endzeit.getDate();
    var minutes = Math.floor((zeit/1000)/60);
    columns['Zeitdifferenz'] = minutes;