APD Toronto
asked on
SQL Date Format
Hello Experts,
I have a SQL SELECT with the following condition:
...AND paymentDate >= '6/20/2012' AND paymentDate <= '7/4/2012'
paymentDate is actually a varchar.
The issue is that my statement does not returns the correct data, and after some digging, I have found that the values in paymentDate are sometimes 2010-04-30 and other times 7/13/2010.
I know that within my SQL SELECT I can take care of it by using I think CAST, but I not exactly sure how to go about doing it.
Any help will be greatly appreciated.
I have a SQL SELECT with the following condition:
...AND paymentDate >= '6/20/2012' AND paymentDate <= '7/4/2012'
paymentDate is actually a varchar.
The issue is that my statement does not returns the correct data, and after some digging, I have found that the values in paymentDate are sometimes 2010-04-30 and other times 7/13/2010.
I know that within my SQL SELECT I can take care of it by using I think CAST, but I not exactly sure how to go about doing it.
Any help will be greatly appreciated.
ASKER CERTIFIED SOLUTION
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
You could use a statement like below to find all bad dates in that table:
select * from table_name where isdate(paymentDate ) = 0