Comparing 2 columns and see which one is greater in an if statement


#1

Attempted to use an if statement to compare if one is greater then do a specific task vs else another.

I tried what was suggested at Comparing stored variables
However used > instead of == making assumptions of get the right answer. Didn’t work. I need an example how I could achieve verifying 2 columns and if one apoch date is greater than another I have stored in a csv


#2

So what you used is this?

if | ${!COL1} > ${!COL2}

or more explicit:

if | parseInt ("${!COL1}") < parseInt ("${!COL2}")

Both should work. In the 2nd version I use parseInt to make sure the string is converted to an integer. If you have decimal numbers, then use parseFloat instead:

if | parseFloat ("${!COL1}") < parseFloat ("${!COL2}")

And if it does not work: Do you get any error message?

Comparison test macro:

{
  "CreationDate": "2018-10-9",
  "Commands": [
    {
      "Command": "store",
      "Target": "8",
      "Value": "A"
    },
    {
      "Command": "store",
      "Target": "22",
      "Value": "B"
    },
    {
      "Command": "if",
      "Target": "${A} < ${B}",
      "Value": ""
    },
    {
      "Command": "echo",
      "Target": "works, A=${A}, B=${B}",
      "Value": ""
    },
    {
      "Command": "endif",
      "Target": "",
      "Value": ""
    }
  ]
}

#3

Could I also use this in a while statement?