Syntax error with beast mode

Trying to convert a column to seconds but I am getting a syntax error and cant figure out where the issue is..

TIME_TO_SEC(`AVG Answer`) + ( DATE_FORMAT(`AVG Answer`, '%f')/1000000)

Best Answer

  • MichelleH
    MichelleH Coach
    edited November 2023 Answer ✓

    @Stucker This looks like a datatype error. If I'm interpreting this correctly, you have a time field (`AVG Answer`) that you are trying to convert into a number of seconds/milliseconds. You are on the right track with the TIME_TO_SEC portion of the formula, but the problem is with the second part where you are looking for the number of milliseconds. The DATE_FORMAT function returns a text value, which cannot be used in mathematical expressions.

    If you want to get down to millisecond granularity, then you will have to use a MagicETL instead of Beast Mode since the Formula Tile supports the MILLISECOND function, which returns a numerical output. Your calculation should look like this:

    TIME_TO_SEC(`AVG Answer`) + ( MILLISECOND(`AVG Answer`)/1000000)
    

Answers

  • MichelleH
    MichelleH Coach
    edited November 2023 Answer ✓

    @Stucker This looks like a datatype error. If I'm interpreting this correctly, you have a time field (`AVG Answer`) that you are trying to convert into a number of seconds/milliseconds. You are on the right track with the TIME_TO_SEC portion of the formula, but the problem is with the second part where you are looking for the number of milliseconds. The DATE_FORMAT function returns a text value, which cannot be used in mathematical expressions.

    If you want to get down to millisecond granularity, then you will have to use a MagicETL instead of Beast Mode since the Formula Tile supports the MILLISECOND function, which returns a numerical output. Your calculation should look like this:

    TIME_TO_SEC(`AVG Answer`) + ( MILLISECOND(`AVG Answer`)/1000000)