jackc/pgx · error

bad interval minute format

Error message

bad interval minute format: %s

What it means

Text interval parsing guard: after splitting the HH:MM:SS[.ffffff] time part, the minutes field failed strconv.ParseInt. The offending minutes substring is included; e.g. '1:x:30' triggers it.

Solutions

  1. Fix the time portion to numeric HH:MM:SS format
  2. Regenerate the interval text via PostgreSQL
Defensive patterns

Strategy: validation

When it happens

Trigger: Thrown at pgtype/interval.go:248 when the library encounters an invalid state.

Common situations: See trigger scenarios.


AI-assisted analysis of jackc/pgx@ec1a0befd2 (2026-08-04). Data as JSON: /api/errors/b94333915b2992f5. Report an issue: GitHub.

Appendix: source

Thrown at pgtype/interval.go:248

		timeParts := strings.SplitN(parts[len(parts)-1], ":", 3)
		if len(timeParts) != 3 {
			return fmt.Errorf("bad interval format")
		}

		var negative bool
		if len(timeParts[0]) > 0 && timeParts[0][0] == '-' {
			negative = true
			timeParts[0] = timeParts[0][1:]
		}

		hours, err := strconv.ParseInt(timeParts[0], 10, 64)
		if err != nil {
			return fmt.Errorf("bad interval hour format: %s", timeParts[0])
		}

		minutes, err := strconv.ParseInt(timeParts[1], 10, 64)
		if err != nil {
			return fmt.Errorf("bad interval minute format: %s", timeParts[1])
		}

		sec, secFrac, secFracFound := strings.Cut(timeParts[2], ".")

		seconds, err := strconv.ParseInt(sec, 10, 64)
		if err != nil {
			return fmt.Errorf("bad interval second format: %s", sec)
		}

		var uSeconds int64
		if secFracFound {
			uSeconds, err = strconv.ParseInt(secFrac, 10, 64)
			if err != nil {
				return fmt.Errorf("bad interval decimal format: %s", secFrac)
			}

			for i := 0; i < 6-len(secFrac); i++ {
				uSeconds *= 10

View on GitHub (pinned to ec1a0befd2)