ISDATE function [Date and time]

Function

Tests whether a string argument can be converted to a date. If a conversion is possible, the function returns 1; otherwise, it returns 0. If the argument is null, 0 is returned.

Syntax

ISDATE ( string )

Parameters

string The string to be analyzed to determine whether the string represents a valid date.

Example

The following example tests whether the birth_date column holds valid dates, returning invalid dates as NULL, and valid dates in date format.

select birth_date from MyData;
------------------------------
1990/32/89,
0101/32/89,
1990/12/09,
select 
  case when isdate(birth_date)=0 then NULL
  else cast(birth_date as date) 
  end 
  from MyData;
------------------------------------
(NULL)
(NULL)
1990-12-09

Standards and compatibility