ISDATE Function [Date and Time]

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

ISDATEstring )

Parameters

Parameters

Parameter

Description

string

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

Returns

INT

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

  • SQL—Vendor extension to ISO/ANSI SQL grammar.

  • Sybase:
    • SQL Anywhere uses ISO 8601 date interchange formats.
    • Not supported by Adaptive Server Enterprise.