Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 8428863
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 10, 20262026-06-10T05:10:26+00:00 2026-06-10T05:10:26+00:00

I have a date column with dates stored as strings, such as 20120817. Unfortunately,

  • 0

I have a date column with dates stored as strings, such as 20120817. Unfortunately, the text form field that populates this column is free text, so I cannot guarantee that an occasional “E” or “whatever” shows up in this column. And more than a few already have.

What I need to do is convert the string column into a date column. Of course the convert will reject the random string characters. Is there any way to create a derived column that will not only convert the strings but exclude the non-date convertible strings?

If there were no non-date convertible strings in the table, the following would work:

ADD [convertedDate] AS CONVERT(DATE, [stringDate], 102)

And it does work perfectly in a test table I created. But when I introduce other non-convertible strings, I receive the dreaded “Conversion failed when converting date and/or time from character string” error for obvious reasons.

Is there a function that will catch non-convertible elements that I can add on to this derived column code? Or is a view or function the only – or best – way to handle this? I played around with IsDate() with little luck.

Thank you!

  • 1 1 Answer
  • 0 Views
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-06-10T05:10:28+00:00Added an answer on June 10, 2026 at 5:10 am

    There’s a function called ISDATE(date), maybe you can use it in a CASE statement or in the WHERE part of the query… It depends on how you’re doing it, maybe something like this

    ADD [convertedDate] AS CASE WHEN ISDATE([stringDate]) = 1 THEN CONVERT(DATE,[stringDate], 102) ELSE NULL END
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have legacy DB that store dates that means no-date as 9999-21-31, The column
I have a date stored within a text field with other text. Why didn't
I have an int column that stored dates as follows: 201101 201102 201103 I
I have a table with a date column that I know is stored in
I have to get dates in my date column in 4 quarters Q1,Q1,Q3,Q4 using
I have a DATE column that I want to round to the next-lower 10
I have a dataset which stores dates in a DataColumn (datatype of this column
I have data stored in a mySQL table under the column type timestamp that
I have a date column which is in YYYYMMDD or 20120101 format. This is
I have a date column where the date is displayed in the format 2009-11-18

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.