manibad (4/17/2013)
Hi,I have a table like the one mentioned below.
EidVariable
1na
2none
34/18/2013
418/2013
52013
69999999
I need to check for eid where variable column has data in the format mm/dd/yyyy and if suppose its not there i should neglect that particular eid.
i shloud do this validation in SSIS.
In informatica i can use IS_Date function but do we have any fucntions similar to is_date in SSIS?
Please help me in this.
Thanks in advance
Note:Column names are just mentioned for instances
I'm sure it can be done in SSIS but any "is date" function my have problems depending on what it thinks a date is. To get around that, you may have to use both ISDATE and a pattern match to guarantee the correct format.
Borrowing heavily on Lowell's test data (which you should supply in this format in the future), here's how to do it in T-SQL. I'd do it for you in SSIS but I don't even know how to spell it correctly. 😛
WITH MySampleData (Eid,Variable)
AS
(
SELECT '1','na' UNION ALL
SELECT '2','none' UNION ALL
SELECT '3','4/18/2013' UNION ALL
SELECT '4','18/2013' UNION ALL
SELECT '5','2013' UNION ALL
SELECT '6','9999999'
)
SELECT Eid,Variable
FROM MySampleData
WHERE 1 = CASE
WHEN ISDATE(Variable) = 1
AND Variable LIKE '[0-9]%/[0-9]%/[0-9][0-9][0-9][0-9]'
THEN 1
ELSE 0
END
;
--Jeff Moden
Change is inevitable... Change for the better is not.