DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE
 
 
SITE SEARCH SQLUSA.com VIDEOS
 
 
SQL E/BOOKS   WORLD, USA & SQL NEWS   FORMAT
SCRIPTS SQL 2005 SQL 2008 ARTICLES
How to validate a date?

Execute the following Microsoft SQL Server T-SQL scripst in SSMS Query Editor to validate a date. It returns TRUE or FALSE (1 or 0):

SELECT  ISDATE('01/06/2008')

-- 1

SELECT  ISDATE(20101231)

-- 1

SELECT  ISDATE(GETDATE())

-- 1

SELECT  ISDATE(CURRENT_TIMESTAMP)

-- 1

SELECT  ISDATE('01/32/2012')

-- 0

SELECT DateCheck=Convert(varchar,CURRENT_TIMESTAMP) + ' IS A VALID DATE'

WHERE ISDATE(CURRENT_TIMESTAMP) = 1

-- Aug 16 2011  7:46AM IS A VALID DATE

-- ISDATE is language setting dependent

SELECT ISDATE('21/6/2012')

-- 0

SET LANGUAGE british

-- Changed language setting to British.

 

SELECT ISDATE('21/6/2012')

-- 1

Related article:

http://www.sqlusa.com/bestpractices/datetimeconversion/

BOL: ISDATE (Transact-SQL)

 

Exam Prep 70-461
SQL 2016 DESIGN & PROGRAMMING
 
 
 
DATETIME SELECT SELECT INTO DATE PAD STRING DYNAMIC SQL CURSOR MONEY FORMAT PERCENT STORED PROCEDURE SQL SERVER AGENT JOB OPTIMIZATION WHILE LOOP OVER PARTITION BY UPDATE