Data Factory Variable Comparison not working as expected.

Robert Barat (WOW) 26 Reputation points
2020-07-06T00:42:02.493+00:00

Hi All,
I'm running a simple pipeline that takes an input variable, adds 1 day to it, and compares it to another variable.
However, the comparison isn't working as I'm expecting it to. Variable boolTest is set to false after the update of the extractDate variable.
Is there a datatype conversion I need to do to make this work as I expect?

{  
  "name": "Variable Comparison",  
  "properties": {  
    "activities": [  
      {  
        "name": "Set tempExtractDate",  
        "type": "SetVariable",  
        "dependsOn": [],  
        "userProperties": [],  
        "typeProperties": {  
          "variableName": "tempExtractDate",  
          "value": {  
            "value": "@adddays(variables('extractDate'),1)",  
            "type": "Expression"  
          }  
        }  
      },  
      {  
        "name": "Update extractDate",  
        "type": "SetVariable",  
        "dependsOn": [  
          {  
            "activity": "Set tempExtractDate",  
            "dependencyConditions": [  
              "Succeeded"  
            ]  
          }  
        ],  
        "userProperties": [],  
        "typeProperties": {  
          "variableName": "extractDate",  
          "value": {  
            "value": "@variables('tempExtractDate')",  
            "type": "Expression"  
          }  
        }  
      },  
      {  
        "name": "Update boolTest",  
        "type": "SetVariable",  
        "dependsOn": [  
          {  
            "activity": "Update extractDate",  
            "dependencyConditions": [  
              "Succeeded"  
            ]  
          }  
        ],  
        "userProperties": [],  
        "typeProperties": {  
          "variableName": "boolTest",  
          "value": {  
            "value": "@equals(variables('endDate'),variables('extractDate'))",  
            "type": "Expression"  
          }  
        }  
      }  
    ],  
    "variables": {  
      "extractDate": {  
        "type": "String",  
        "defaultValue": "2020-05-29T00:00:00Z"  
      },  
      "tempExtractDate": {  
        "type": "String"  
      },  
      "endDate": {  
        "type": "String",  
        "defaultValue": "2020-05-30T00:00:00Z"  
      },  
      "boolTest": {  
        "type": "Boolean"  
      }  
    },  
    "annotations": []  
  }  
}  

Regards,
-rob

Azure Data Factory
Azure Data Factory

An Azure service for ingesting, preparing, and transforming data at scale.

0 comments No comments

Answer accepted by question author

ChiragMishra-MSFT 956 Reputation points
2020-07-06T06:18:15.023+00:00

Hi @RobBaratWOW,

While comparing the two variables (dates in your case), you need to make sure that they are in the same format. To do so, you can use the formatDateTime function provided by Azure Data Factory. In your "Update boolTest" activity, please try replacing the expression :

 @equals(variables('endDate'),variables('extractDate'))

to

 @equals(formatDateTime(variables('endDate')),formatDateTime(variables('extractDate')))

Hope this helps.

Was this answer helpful?


0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as 'Accepted' by the question author and 'Recommended' by moderators, which helps users know the answer solved the author's problem.