Getting Started with Adobe After Effects - Part 6: Motion Blur


Upload Image Close it
Select File

Browse by Tags · View All
sql_server 217
t-sql 211
tsql 116
sqlserver 96
BRH 78
#SQLServer 66
#TSQL 56
SQL Server 34
function 11
SSMS 9

Archive · View All
August 2007 17
August 2010 8
June 2012 7
June 2011 7
November 2007 7
August 2012 6
May 2012 6
November 2011 6
August 2011 6
October 2011 6

Madhivanan's TSQL Blog

Handle ISDATE() with care

Sep 24 2007 9:30AM by Madhivanan   

Now-a-days it becomes common practice for newbies to use varchar datatype to store dates. My first advice is to use proper DATETIME datatype. Sometimes it is preferred to use varchar when importing dates from other systems(to avoid any errors if the source dates are in different format). In that case it is required to see if values are actually dates. To check if a value is proper date, it is suggested to use ISDATE()

eg

select isdate('2007-10-12'),isdate('12-12-2006'),isdate('March 12, 2007') 

Now it should be noted that the following return 1

select isdate(2007),isdate('2007')

becuase the values in a ISDATE functions are first casted to datetime

select cast(2007 as datetime)                                         

------------------------------------------------------ 
1905-07-01 00:00:00.000
 

select cast('2007' as datetime)                                                
------------------------------------------------------ 
2007-01-01 00:00:00.000

Which are valid dates So if varchar datatype is used to stored formatted dates (ex YYYYMMDD), to check if it is valid date, you need not only to use ISDATE() function, but also use LEN() function Consider the following set of data and see the difference

declare @dates table (dates varchar(8))

insert into @dates(dates)
Select '20071201' union all
Select '20071111' union all
Select '2007' union all
Select 2007 union all
Select '1800' 

select dates from @dates
where ISDATE(dates) =1 
--Result
dates    
-------- 
20071201
20071111
2007
2007
1800

--Result

select dates from @dates
where ISDATE(dates) =1 and LEN(dates)=8


dates    
-------- 
20071201
20071111
  

Tags: t-sql, sql_server, isdate,


Madhivanan
3 · 40% · 12912
2
 
0
Lifesaver
 
0
Refreshed
 
0
Learned
 
0
Incorrect



Submit

Your Comment


Sign Up or Login to post a comment.

"Handle ISDATE() with care" rated 5 out of 5 by 2 readers
Handle ISDATE() with care , 5.0 out of 5 based on 2 ratings
    Copyright © Rivera Informatic Private Ltd Contact us      Privacy Policy      Terms of use      Report Abuse      Advertising      [ZULU1097]