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
 SQL Server Development (2000)
 ignoring invalid dates

Author  Topic 

mikejohnson
Posting Yak Master

153 Posts

Posted - 2004-07-08 : 18:03:07
i want to check for a valid date in my records. if it isn't, i just want to return null or ''. if not, return the date. here is my sql statement so far. i tried adding if/else code with isdate() but it didn't work.

select (p.strdobmonth + '/' + p.strdobday + '/' + p.strdobyear) as dtDOB from p

ehorn
Master Smack Fu Yak Hacker

1632 Posts

Posted - 2004-07-08 : 18:29:59
[code]
SELECT CASE WHEN ValidDate = 1 THEN DOB ELSE NULL END DOB
FROM
(
select
ISDATE(convert(varchar(2),strdobmonth) + '/' + convert(varchar(2),strdobday) + '/' + convert(varchar(4),strdobyear)) ValidDate,
convert(varchar(2),strdobmonth) + '/' + convert(varchar(2),strdobday) + '/' + convert(varchar(4),strdobyear) DOB
from dtDOB
) d[/code]
Go to Top of Page
   

- Advertisement -