Link to home
Start Free TrialLog in
Avatar of amrelgarhy81
amrelgarhy81Flag for Egypt

asked on

SQL filter isdate ?

Hello,
I have a table in sql server database contains varchar field, in this field records there is some records contains valid date values and some records contains characters "not date value".

What i want is write a filter to get the records which contains the valid date values only.

Something like:
select * from MyTable where MyField IsDate


Thanks,
ASKER CERTIFIED SOLUTION
Avatar of Guy Hengel [angelIII / a3]
Guy Hengel [angelIII / a3]
Flag of Luxembourg image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
note: the IsDate() will return 1 if the string value matches the current DATEFORMAT setting, which can be either YMD, DMY or MDY.
you will get different results of IsDate() based on that setting.
SOLUTION
Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
so, in a filter, you can then use that function as if it were a legitimate datetime ( not neccessarily recommended for very large tables ) as in

select * from mytable where isnull(dbo.uValidDate(mycolumn),'19000101') between getdate()  - 90 and getdate()

but then AngelIII's use of isdate probably answers your question...