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 8802149
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T01:01:04+00:00 2026-06-14T01:01:04+00:00

How can I gracefully handle bad date integers that are random thorughout my table?

  • 0

How can I gracefully handle bad date integers that are random thorughout my table? For instance I see some 9999999999 in there at times so consequently this query bombs out. I want to just produce the 1900 date in those cases instead of just stopping like this:

Select convert(date,CAST(trandate as varchar(8))),
       convert(date,CAST(duedate as varchar(8))), 
        ...

FROM  SomeTable

a valid date looks like this in that table for those fields: 20100924 and those work fine when they hit this query.

  • 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-14T01:01:05+00:00Added an answer on June 14, 2026 at 1:01 am

    You can use the isdate built-in function in sql server to check if something is castable to a date and then handle it however.

    Example:

    declare @mytable table (thedate varchar(20))
    insert into @mytable values ('20100924')
    insert into @mytable values ('99999')
    
    select 
    case when isdate(thedate)=1 then
        CAST(thedate as datetime)
    else null end as foo
    from @mytable
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

Is there a PostgreSQL HA solution that can handle a splitbrain situation gracefully. To
Pretty simple question that I can't quite find the answer for: Is there a
I want to gracefully handle a specific exception with a certain message. Unfortunately, it's
Here is what I did, I want to gracefully handle this exception: code_snippet: my.cpp
What is the best way in node to handle unhandled expections that are coming
How can I gracefully shutdown a Java SSL session without closing the underlying socket?
In my WiX installer I want to gracefully close the application that is about
There is a common problem that F# does not natively support infix-style use of
I wanted to handle all internal errors gracefully, without program termination. As discussed here
I have an <iframe> that other sites can include so their users can POST

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.