# invalid input syntax for type date: "March 1"

Source: https://sqlstreak.com/sql/errors/invalid-input-syntax-for-type-date · Tested on PostgreSQL 18.6 and SQLite 3.54.1; results generated 2026-11-22.


**Short answer:** PostgreSQL couldn't read the text as a date. Write dates as `'YYYY-MM-DD'`, such as `'2026-03-15'`: that form works in every database, and in SQLite it also sorts correctly as text.

## The exact messages

- PostgreSQL: `ERROR: invalid input syntax for type date: "March 1"`

## How PostgreSQL prints it

```
ERROR:  invalid input syntax for type date: "March 1"
LINE 3: WHERE ordered_on > 'March 1';
                           ^
```

## Why it happens

### A date without a year, or in words

`'March 1'` or `'1st March'` isn't a full date. Use `'2026-03-01'`.

### A day that doesn't exist

`'2026-02-30'` or month 13 gives a related message: `date/time field value out of range`.

### An empty string from an import

`''` isn't a date either. Turn blanks into NULL first: `NULLIF(col, '')::date`.

## The broken query

```sql
SELECT id, ordered_on
FROM orders
WHERE ordered_on > 'March 1';
```

## The fix

```sql
SELECT id, ordered_on
FROM orders
WHERE ordered_on > '2026-03-15';
```

ISO dates (`YYYY-MM-DD`) are read the same way by PostgreSQL and compare correctly as text in SQLite.

| id | ordered_on |
| --- | --- |
| 14 | 2026-03-18 |
| 15 | 2026-03-20 |
| 16 | 2026-03-22 |
| 17 | 2026-03-22 |

## What SQLite does instead

SQLite stores dates as text and compares text with text, so `ordered_on > 'March 1'` compares letters with digits. It returns no rows and no error, which is worse: the query looks fine and is wrong.
