Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2000 Forums
 Transact-SQL (2000)
 Date Validation in SQL

Author  Topic 

giri_sayee
Starting Member

1 Post

Posted - 2006-10-06 : 12:55:43
I need to validate that a varchar column is in yyyy/mm/dd format.
Is there a earier way to do this other than doing substring and finding length of each datepart?

X002548
Not Just a Number

15586 Posts

Posted - 2006-10-06 : 13:08:05
[code]
DECLARE @d varchar(10)
SET @d = '2006/10/06'
IF (SELECT ISDATE(@d))=1
PRINT 'Valid Date'
ELSE
PRINT 'Inalid Date'

[/code]


Brett

8-)

Hint: Want your questions answered fast? Follow the direction in this link
http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx

Add yourself!
http://www.frappr.com/sqlteam



Go to Top of Page
   

- Advertisement -