Geeks With Blogs
Ben Adler's Development Posting solutions as I find them

-- use this case statement to convert a value (column) to a date in the format mm/dd/yyyy. If converting to a date is not possible, the column will be null

 

select

      case

            when isdate(value) =1  then

                  convert(varchar,convert(datetime, value, 101), 101)

      end as [Date]

from

      MyTable

Posted on Friday, May 6, 2011 3:16 PM SQL | Back to top


Comments on this post: SQL Convert to Date if possible

No comments posted yet.
Your comment:
 (will show your gravatar)


Copyright © BenAdler | Powered by: GeeksWithBlogs.net