getredash/redash · error · Exception

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

Error message

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

What it means

GA4 runner's format_column_value normalizes typed columns; for TYPE_DATETIME it accepts exactly 10-char (YYYYMMDDHH) or 12-char (YYYYMMDDHHMM) values, otherwise raises 'Unknown date/time format in results'. It fires during parsing of every row, including in test_connection-adjacent code paths.

Source

Thrown at redash/query_runner/google_analytics4.py:52

    DATETIME=TYPE_DATETIME,
)

ga_report_endpoint = "https://analyticsdata.googleapis.com/v1beta/properties/{propertyId}:runReport"
ga_metadata_endpoint = "https://analyticsdata.googleapis.com/v1beta/properties/{propertyId}/metadata"


def format_column_value(column_name, value, columns):
    column_type = [col for col in columns if col["name"] == column_name][0]["type"]

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

    return value


def get_formatted_column_json(column_name):
    data_type = None

    if column_name == "date":
        data_type = "DATE"
    elif column_name == "dateHour":
        data_type = "DATETIME"

    result = {
        "name": column_name,
        "friendly_name": column_name,
        "type": types_conv.get(data_type, "string"),
    }

View on GitHub (pinned to ca79fe988d)

Solutions

  1. Change the dimension to dateHour/dateHourMinute so the value matches a supported length
  2. Pre-check your values: ensure 10- or 12-char zero-padded strings before relying on datetime typing
  3. File/upgrade Redash so format_column_value handles 'YYYYMMDD' and None

Example fix

// before
{"dimensions": [{"name": "date"}]}
// after
{"dimensions": [{"name": "dateHour"}]}
Defensive patterns

Strategy: validation

Validate before calling

import re

def is_supported_dt(v) -> bool:
    if not isinstance(v, str):
        return False
    return bool(re.fullmatch(r"\d{10}|\d{12}", v))

Try / catch

try:
    rows = runner.run_query(q, user)
except Exception as e:
    if "Unknown date/time format" in str(e):
        change_column_type_to_date_or_string_and_refresh()

Prevention

When it happens

Trigger: A GA4 dimension typed as datetime whose value is 'YYYYMMDD' (8 chars), empty, None, or a new granularity like dateHourMinute with different length; also raw values not zero-padded.

Common situations: Using ga:date (8 chars) where the type inference marks the column datetime, API returning nulls in sparse rows, or newer GA4 dimensions with unrecognized formats.

Related errors


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