SQL functions: PostgreSQL and SQLite, tested
The functions where PostgreSQL and SQLite differ most. Each page has the syntax in both, examples, and a table of edge cases run on both engines, so you see what really comes back.
| Function | What it does | PostgreSQL | SQLite |
|---|---|---|---|
| strftime | strftime(format, date, modifiers…) turns a date or time into text in the format you give: strftime('%Y-%m', '2026-03-15') returns '2026-03'. | No: use to_char() or EXTRACT() | Yes, built in |
| date | date(value, modifier, …) returns a date as 'YYYY-MM-DD' text after applying the modifiers in order: date('2026-03-15', '+7 days') is '2026-03-22'. | No date() function: use date arithmetic and date_trunc | Yes, built in |
| julianday | julianday(date) returns the date as a Julian day number, a decimal count of days, so julianday(d2) - julianday(d1) is the number of days between two dates. | No: subtract dates; to_char(d, 'J') gives a whole Julian day number | Yes, built in |
| string_agg / group_concat | string_agg(value, separator) is an aggregate that joins the values of a group into one string: string_agg(name, ', ' ORDER BY name). | string_agg: yes. group_concat: no | Both (string_agg since 3.44) |
| substr | substr(text, start, length) returns part of a string, counting from 1: substr('Biscuit', 1, 3) is 'Bis'. | Yes | Yes |
| instr / strpos / position | SQLite's instr(text, part) returns the position of the first occurrence of part, counting from 1, or 0 if it isn't there. | strpos and POSITION: yes. instr: no | instr: yes. strpos, POSITION: no |
| printf / format | SQLite's printf(format, values…) (also called format()) fills placeholders C-style: printf('%.2f', 3.14159) is '3.14'. | format: yes (text only). printf: no | printf and format: yes |
| COALESCE / IFNULL | COALESCE(a, b, …) returns the first argument that isn't NULL: COALESCE(breed, 'mixed') shows 'mixed' where the breed is missing. | COALESCE: yes. IFNULL: no | Both |
| NULLIF | NULLIF(a, b) returns NULL when a equals b, and a otherwise. | Yes | Yes |
| CAST | CAST(value AS type) converts a value to another type: CAST('42' AS INTEGER) is the number 42. | Yes, plus the :: shorthand | Yes (no ::) |
| ROUND | ROUND(x, n) rounds x to n decimal places (to a whole number without n): ROUND(13.456, 2) is 13.46. | Yes (with digits only for numeric) | Yes |
| REPLACE | REPLACE(text, from, to) returns the text with every occurrence of from swapped for to: REPLACE('555-0101', '-', '') is '5550101'. | Yes | Yes |