Date Math Transform ISO8601 Format Error

We have a start date in format yyyy-MM-dd and that is being converted to ISO8601. This is being populated as expected.

Transform:

{

"attributes": {

    "inputFormat": "yyyy-MM-dd",

    "outputFormat": "ISO8601"

},

"id": "Date Format",

"type": "dateFormat"

}

image

To calculate an end date, we want to add 1 year.

Transform:

{

"attributes": {

    "expression": "+1y",

    "input": {

        "attributes": {

            "input": {

                "attributes": {

                    "attributeName": "start_date",

                    "sourceName": "Source Name"

                },

                "type": "accountAttribute"

            },

            "inputFormat": "yyyy-MM-dd",

            "outputFormat": "ISO8601"

        },

        "type": "dateFormat"

    },

    "roundUp": true

},

"type": "dateMath",

"name": "End Date"

}

However, this is being populated in the format
yyyy-mm-ddT00:00Z

rather than
yyyy-mm-ddT00:00:00.000Z

image

This is causing issues downstream when this value is being parsed as it is not recognized as valid ISO8601.

Hi Edward,

You’re seeing this format for end date because the output of dateMath transform is not formatted as ISO8601 — it formats date as yyyy-MM-dd’T’HH:mm … You’ll need to put that entire transform as input in a dateFormat transform to convert it to ISO8601. FYI - the dateMath Compass article mentions the required input format for date (ISO8601) and how it formats the output (yyyy-MM-dd’T’HH:mm).

Thanks,
Lisa Ivy

@lisa_ivy Thanks, I see that now. Is there a reason that it converts to that format rather than keeping it in ISO8601? Is there a name for that format?

Sorry, I don’t know the reasoning on why the transform has the output in that format, rather than ISO8601. I don’t think that format has a formal name.

Here’s the new transform. Note that you’ll have to delete the old transform and create a new one (if you want to use the same name) because if you try to PUT and replace the existing transform, you’ll receive an error because it has a different transform type (as the outmost operation).

{
  "attributes": {
      "input": {
        "attributes": {
          "expression": "+1y",
          "input": {
              "attributes": {
                  "input": {
                      "attributes": {
                          "attributeName": "start_date",
                          "sourceName": "Source Name"
                      },
                      "type": "accountAttribute"
                  },
                  "inputFormat": "yyyy-MM-dd",
                  "outputFormat": "ISO8601"
              },
              "type": "dateFormat"
          },
          "roundUp": true
      },
      "type": "dateMath"
      },
      "inputFormat": "yyyy-MM-dd'T'HH:mm",
      "outputFormat": "ISO8601"
  },
  "type": "dateFormat",
  "name": "End Date"
}

Thanks,
Lisa Ivy

2 Likes

Thanks @lisa_ivy, I have made those changes and this has resolved our issue.

2 Likes