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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 28, 20262026-05-28T05:38:51+00:00 2026-05-28T05:38:51+00:00

I am using sqlserver to store/search. The problem is I have a form which

  • 0

I am using sqlserver to store/search. The problem is I have a form which takes start date and end date to search. If I enter dates after 1753 then no problem. If I enter any date below 1752, I am getting the below exception:

The conversion of a char data type to a datetime data type resulted in an out-of-range datetime value. 

I know sql server supports date range b/w 1753 and 9999. But I cannot prevent the user from entering dates below 1753. Please help me.

Thanks!

  • 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-05-28T05:38:52+00:00Added an answer on May 28, 2026 at 5:38 am

    If you need to store dates before 1753 in SQL Server 2005, then you’re going to have to store it as text.

    If you’re storing the date only (no time component), then I’d recommend:

    CREATE TABLE Tab (
        /* Other Columns */,
        FunnyDate char(8) not null,
        constraint CK_FunnyDate_MostlyValid CHECK (
            FunnyDate like '[0-9][0-9][0-9][0-9][0-1][0-9][0-3][0-9]')
        /* Other constraints */
    )
    

    Which should force it to closely resembly a valid date (in YYYYMMDD format). You might also consider adding a computed column, which represents it as a datetime, if it’s convertible to such a value.

    If you need to include a time component, I’d recommend storing it in YYYY-MM-DD"T"hh:mm:ss format, and again enforced by a check constraint.

    The formats I’ve recommended above are safely convertible to datetimes without having to consider regional settings.

    You can also write stricter check constraints, if needed (e.g. the above does allow a 14th month, for example)

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I've written a paged search stored procedure using SQL Server 2005. It takes a
I have been spoiled by either using sql server to store data, or using
I'm using MS SQL Server 2005 and I need to store date values partially.
I am using MS SQL Server 2005, I have dates stored in epoch time
I have a very simple problem which requires a very quick and simple solution
I have c# project that is using sqlserver compact edition and entity framework for
I am using FileStream datatype in SQLServer 2008 to store attachments. My apprehension is
I have an application in Asp.net and using sql server to store user information.
I am using SQL Server, and wants to store only the date part, if
I am using SQL Server 2008. I have a table which has a datetime

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.