getredash/redash · error · Exception

Unknown date/time format in results: '{}'

Error message

Unknown date/time format in results: '{}'

What it means

GA v3 returns date/datetime columns as compact strings (YYYYMMDD, YYYYMMDDHH, YYYYMMDDHHMM). parse_ga_response only accepts lengths 10 and 12 for TYPE_DATETIME; anything else (including the 8-char date form in a datetime column) raises 'Unknown date/time format in results'.

Source

Thrown at redash/query_runner/google_analytics.py:81

                if "primitiveValue" in value:
                    value = value["primitiveValue"]
                elif "conversionPathValue" in value:
                    steps = []
                    for step in value["conversionPathValue"]:
                        steps.append("{}:{}".format(step["interactionType"], step["nodeValue"]))
                    value = ", ".join(steps)
                else:
                    raise Exception("Results format not supported")

            if column_type == TYPE_DATE:
                value = datetime.strptime(value, "%Y%m%d")
            elif column_type == TYPE_DATETIME:
                if len(value) == 10:
                    value = datetime.strptime(value, "%Y%m%d%H")
                elif len(value) == 12:
                    value = datetime.strptime(value, "%Y%m%d%H%M")
                else:
                    raise Exception("Unknown date/time format in results: '{}'".format(value))

            d[column_name] = value
        rows.append(d)

    return {"columns": columns, "rows": rows}


class GoogleAnalytics(BaseSQLQueryRunner):
    should_annotate_query = False

    @classmethod
    def type(cls):
        return "google_analytics"

    @classmethod
    def name(cls):
        return "Google Analytics"

View on GitHub (pinned to ca79fe988d)

Solutions

  1. Change the dimension/metric so values match YYYYMMDDHH or YYYYMMDDHHMM (e.g. use ga:dateHour, not ga:date, for datetime columns)
  2. Cast the column to string/type BOOLEAN in the query's column hints if present
  3. Upgrade Redash, where parsing of additional formats may be added

Example fix

// before
{"dimensions": "ga:date"}
// after
{"dimensions": "ga:dateHour"}
Defensive patterns

Strategy: validation

Validate before calling

def valid_datetime_len(v: str) -> bool:
    return isinstance(v, str) and len(v) in (10, 12) and v.isdigit()

Try / catch

try:
    data = runner.run_query(q, user)
except Exception as e:
    if "Unknown date/time format" in str(e):
        switch_dimension_to_date_and_retry()  # ga:date + date typing

Prevention

When it happens

Trigger: A ga:dateHourNth (or sampled) column whose value length is not 10 or 12, or a value that is None/empty when the column type was inferred as datetime — e.g. '20240101' (length 8) in a datetime column.

Common situations: GA API changes adding new granularity (dateHourMinute variants), rows with missing values, or dimensions like ga:date paired with inferred datetime typing.

Related errors


AI-assisted analysis of getredash/redash@ca79fe988d (2026-08-28). Data as JSON: /api/errors/d5bbae29607844b5. Report an issue: GitHub.