Which date functions should I know, and how do the engines differ?
Interviews usually test three families. First, extracting parts of a date: the year, the month, the day of the week. Second, truncating a timestamp to a period — to the month, the quarter, the week. Third, arithmetic: adding days, and measuring the gap between two dates.
The dialects diverge sharply here. SQLite uses strftime with a format string for both extraction and truncation: Oracle has EXTRACT, TRUNC for date truncation and ADD_MONTHS.strftime('%Y', d) gives the year, SQL Server has DATEPART, DATETRUNC from version 2022, and DATEADD for arithmetic.strftime('%Y-%m', d) gives the month, and PostgreSQL has EXTRACT, date_trunc, to_char and an interval type.strftime('%Y-01-01', d) truncates to the start of the year. MySQL has the DATE, YEAR, MONTH and EXTRACT functions plus DATE_FORMAT for formatting, and LAST_DAY for month ends.
Three portability notes. NOW(), CURDATE() and GETDATE() are all different; the standard spelling of the current timestamp is CURRENT_TIMESTAMP, and in SQLite the equivalent is datetime('now'). And the interval arithmetic is the least portable area of all: d1 - d2 gives a number of days in SQLite, an interval in PostgreSQL, and a datetime in MySQL, so any difference calculation needs a dialect-specific expression.
One more decision that matters more than the function choice: whether to store dates as native date types or as text. Native types give you correct comparison, arithmetic and indexing. Text in ISO-8601 format compares correctly lexicographically, which is why it often works, but it silently breaks the moment someone writes '2026-3-7' instead of '2026-03-07' — and it gives you no date functions at all.