// conversion reference

SQL ISDATE function

ISDATE(s) returns 1 when s converts to datetime. The answer depends on session settings, which makes it a poor validator for imported data.

카테고리
Conversion
Returns
int (1 or 0)
In this category
38 of 39

구문

ISDATE(expression)

엔진 지원

엔진Support메모
SQL Server 예 Supported under this name.
PostgreSQL Different name or syntax pg_input_is_valid(s, 'date') from 16
MySQL Different name or syntax STR_TO_DATE(s, format) IS NOT NULL
SQLite Different name or syntax date(s) = s; date() alone moves 2026-02-30 to March
Oracle Different name or syntax VALIDATE_CONVERSION(s AS DATE, 'YYYY-MM-DD') from 12.2

예시

SQL Server

SELECT ISDATE('2026-02-30') AS feb30, ISDATE('2026-02-28') AS feb28, ISDATE('2026') AS year_only;  -- 0, 1, 1

PostgreSQL

SELECT pg_input_is_valid('2026-02-30', 'date') AS feb30, pg_input_is_valid('2026-02-28', 'date') AS feb28;  -- f, t

SQLite

SELECT date('2026-02-30') AS normalized, date('2026-02-30') = '2026-02-30' AS is_valid;  -- 2026-03-02, 0

MySQL

SELECT STR_TO_DATE('2026-02-30', '%Y-%m-%d') AS feb30, STR_TO_DATE('2026-02-28', '%Y-%m-%d') AS feb28;  -- NULL, 2026-02-28

알아 두면 좋은 정보

  • ISDATE reads the string with the session's DATEFORMAT and language: '13/01/2026' is 1 under SET DATEFORMAT dmy and 0 under mdy.
  • ISDATE tests against datetime, so more than three fractional digits fail: ISDATE('2026-01-01 10:00:00.1234567') is 0 although datetime2 accepts the value. TRY_CAST(s AS datetime2) IS NOT NULL avoids that.
  • ISDATE('2026') is 1: a four-digit year on its own is a valid datetime string.
  • SQLite's date() normalizes an out-of-range day instead of rejecting it: date('2026-02-30') returns 2026-03-02. Compare the result with the input to catch impossible dates.

Questions about ISDATE

ISDATE or TRY_CAST?

TRY_CAST, or TRY_CONVERT with an explicit style. ISDATE only knows datetime and depends on session settings; TRY_CONVERT(date, s, 23) checks one exact format.

How do I find the bad date strings in a column?

SELECT raw FROM staging WHERE raw IS NOT NULL AND TRY_CONVERT(date, raw, 23) IS NULL on SQL Server; on PostgreSQL 16+ use NOT pg_input_is_valid(raw, 'date').

Browse every function in the SQL function reference, or see what the SQLly desktop app does for your database.

Cheat sheets for the engines that have it: SQL Server, PostgreSQL, MySQL, SQLite, Oracle.

// fewer lookups

Functions your engine actually has

SQLly's completion lists the built-in functions of the engine you're connected to, whether that's SQL Server, PostgreSQL, MySQL, SQLite or Oracle. Hover a function for help, and signature hints show each argument as you type.