SQL error
function … does not exist / no such function
Updated · Tested on PostgreSQL 18.6 and SQLite 3.54.1 (results generated , re-checked on every release)
Short answer
The database has no function with that name for those arguments. Usually it's a function from another database (DATEDIFF is MySQL and SQL Server, strftime is SQLite, now() is PostgreSQL), or, in PostgreSQL, the right function with the wrong argument types.
The exact messages
- PostgreSQLERROR: function datediff(unknown, date) does not exist
- SQLiteno such function: DATEDIFF
How to read this message
This is what PostgreSQL 18.6 prints for the broken query below, the way psql shows it. LINE gives the line it was reading when it gave up, and the ^ marks the exact spot. HINT is PostgreSQL's own suggestion, and it's usually worth following.
ERROR: function datediff(unknown, date) does not exist
LINE 1: SELECT id, DATEDIFF('2026-03-31', ordered_on) AS days_ago
^
HINT: No function matches the given name and argument types. You might need to add explicit type casts.SQLite 3.54.1 reports the same mistake as no such function: DATEDIFF, with no line number: look for the word or column it names.
Why it happens
A function from another database
Date and text functions differ most between databases. DATEDIFF, DATE_FORMAT, GETDATE() and ISNULL() don't exist in PostgreSQL or SQLite; each has its own equivalent.
The right name, the wrong argument types (PostgreSQL)
PostgreSQL matches functions by name and argument types. ROUND(x, 2) exists for numeric, not for double precision, so it reports function round(double precision, integer) does not exist. Cast the argument.
A typo or a missing extension
Check the spelling. Some functions need an extension that isn't installed, which also looks like this error.
Reproduce it, then fix it
Both queries run on a real database in your browser. Switch dialects to compare.
SELECT id, DATEDIFF('2026-03-31', ordered_on) AS days_ago
FROM orders;SELECT id, DATE '2026-03-31' - ordered_on AS days_ago
FROM orders;Each database has its own date arithmetic: PostgreSQL subtracts one date from another and gets days; SQLite turns dates into day numbers with julianday() first.
The fix returns, PostgreSQL: first 6 of 17 rows
| id | days_ago |
|---|---|
| 1 | 30 |
| 2 | 30 |
| 3 | 28 |
| 4 | 27 |
| 5 | 26 |
| 6 | 26 |
The fix returns, SQLite: first 6 of 17 rows
| id | days_ago |
|---|---|
| 1 | 30 |
| 2 | 30 |
| 3 | 28 |
| 4 | 27 |
| 5 | 26 |
| 6 | 26 |
Experiment with it: PostgreSQL playground·SQLite playground
Other forms of this mistake
Each one was run when this page was built; the result is what the engine really does.
SELECT ROUND(AVG(price)::float, 2) FROM menu_items;PostgreSQLERROR: function round(double precision, integer) does not exist
The function exists, but not for a double precision argument. Write
ROUND(AVG(price)::numeric, 2)instead.SELECT strftime('%Y', ordered_on) FROM orders;PostgreSQLERROR: function strftime(unknown, date) does not exist
strftime is SQLite's. In PostgreSQL use
to_char(ordered_on, 'YYYY')orEXTRACT(YEAR FROM ordered_on).SELECT now();SQLiteno such function: now
now() is PostgreSQL's. In SQLite use
datetime('now')ordate('now').SELECT ROUND(AVG(price)::numeric, 2) FROM menu_items;PostgreSQLRuns without an error
Casting to numeric makes ROUND(x, 2) work in PostgreSQL.
Official documentation
Stop hitting this error
Practise the concept behind it in a five-minute lesson, or read the full guide: PostgreSQL vs SQLite: SQL syntax differences.