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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 25, 20262026-05-25T19:57:13+00:00 2026-05-25T19:57:13+00:00

I Have a table called Sur_Data and the data looks like: ID SV_Date 258

  • 0

I Have a table called Sur_Data and the data looks like:

ID     SV_Date
258    13/01/2010
569    15/02/2011
695    26/05/2010
745    12/06/2010

Now I want to select the ID’s from that table and insert into another table so we are using something like:

Insert into Surdate(ID)
Select ID from Sur_Data
where ISDATE(SV_Date) = 1

Since the format in SV_Date is different it is not inserting any records into Surdate table.

So I am trying to see is there a way that we could restrict the data in Sur_Data table to have only date’s that are in MM/DD/YYYY format.So whenever they try to insert records of different format it should throw an error.

Can anyone help on this?

  • 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-25T19:57:13+00:00Added an answer on May 25, 2026 at 7:57 pm

    Edit: for example 2 & 3, ANSI WARNINGS must be off.

    IS_DATE function is influenced by DATEFORMAT setting for current SQL Server session/connection.

    Example 1:

    DECLARE @d1 VARCHAR(25) = '26/05/2010'
            ,@d2 VARCHAR(25) = '15/02/2011';
    
    PRINT '*****Test 1*****'        
    SET DATEFORMAT DMY;
    SELECT  ISDATE(@d1), ISDATE(@d2);       
    
    PRINT '*****Test 2*****'        
    SET DATEFORMAT MDY;
    SELECT  ISDATE(@d1), ISDATE(@d2);
    

    Results:

    *****Test 1*****
    
    ----------- -----------
    1           1
    
    (1 row(s) affected)
    
    *****Test 2*****
    
    ----------- -----------
    0           0
    
    (1 row(s) affected)
    

    Now, you can see how DATEFORMAT influences ISDATE function.
    Instead of ISDATE function you can use CONVERT function with different date/time styles. If a [n][var]char value doesn’t have the selected style then CONVERT function will return NULL. For dd/mm/yyyy values (british) can be used style 103 and for mm/dd/yyyy values (U.S.) can be used style 101.

    Example 2:

    SET ANSI_WARNINGS OFF;
    SET ARITHABORT OFF;
    
    DECLARE @Results TABLE
    (
        ID INT PRIMARY KEY
        ,SV_Date VARCHAR(20) NOT NULL
    );
    
    INSERT  @Results 
    VALUES
     (258,    '13/01/2010')
    ,(569,    '15/02/2011')
    ,(695,    '26/05/2010')
    ,(745,    '12/06/2010');
    
    SELECT  *
            ,ISDATE(r.SV_Date) [IS_DATETIME]
            ,CONVERT(DATETIME,r.SV_Date,103) [IS_DATETIME British/French style=dd/mm/yyyy]
            ,CONVERT(DATETIME,r.SV_Date,101) [IS_DATETIME U.S. style=mm/dd/yyyy]
            ,CASE 
                WHEN CONVERT(DATETIME,r.SV_Date,103) IS NOT NULL AND CONVERT(DATETIME,r.SV_Date,101) IS NULL THEN 'IS_DMY'
                WHEN CONVERT(DATETIME,r.SV_Date,103) IS NULL AND CONVERT(DATETIME,r.SV_Date,101) IS NOT NULL THEN 'IS_MDY'
                WHEN CONVERT(DATETIME,r.SV_Date,103) IS NOT NULL AND CONVERT(DATETIME,r.SV_Date,101) IS NOT NULL THEN 'IS_DMY_OR_MDY'
                WHEN CONVERT(DATETIME,r.SV_Date,103) IS NULL AND CONVERT(DATETIME,r.SV_Date,101) IS NULL THEN 'IS_NOT_DMY_OR_MDY'
            END
    FROM    @Results r;
    

    Results:

    ID          SV_Date              IS_DATETIME IS_DATETIME British/French style=dd/mm/yyyy IS_DATETIME U.S. style=mm/dd/yyyy 
    ----------- -------------------- ----------- ------------------------------------------- --------------------------------- -----------------
    258         13/01/2010           0           2010-01-13 00:00:00.000                     NULL                              IS_DMY
    569         15/02/2011           0           2011-02-15 00:00:00.000                     NULL                              IS_DMY
    695         26/05/2010           0           2010-05-26 00:00:00.000                     NULL                              IS_DMY
    745         12/06/2010           1           2010-06-12 00:00:00.000                     2010-12-06 00:00:00.000           IS_DMY_OR_MDY
    

    Now, if you want to check SV_Date values for mm/dd/yyyy format (style 101 – U.S.) then you can use a CHECK constraint like this:

    Example 3:

    DECLARE @Results2 TABLE
    (
        ID INT PRIMARY KEY
        ,SV_Date VARCHAR(20) NOT NULL
        ,CHECK( CONVERT(DATETIME,SV_Date,101) IS NOT NULL )
    );
    SET ANSI_WARNINGS OFF;
    INSERT  @Results2 
    VALUES  (258,    '13/01/2010');
    INSERT  @Results2 
    VALUES  (569,    '15/02/2011');
    INSERT  @Results2 
    VALUES  (695,    '26/05/2010');
    INSERT  @Results2 
    VALUES  (745,    '12/06/2010');
    SELECT  *
    FROM    @Results2;
    

    Results:

    ID          SV_Date
    ----------- --------------------
    745         12/06/2010
    
    (1 row(s) affected)
    

    Observations:
    If you want to find current DATEFORMAT setting (current session) then you can use sys.dm_exec_sessions view:

    SELECT  s.date_format, s.date_first
    FROM    sys.dm_exec_sessions s
    WHERE   s.session_id = @@SPID 
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have table called Data_Details and the data looks like: DateTimeClosed Datesub TimeSub 6/20/2011
I have a table called reports it looks like: user_id | report_post 1 2
i have table called table1 and it looks like the below record type tran_ref_number
I have a Table called Product and I have the Table StorageHistory . Now,
I have table called Direccion other called Cliente each one defined like this public
i have table called type which contains data family,individual i want in some pages
I have a table called jobs and I can get data out of the
hi i have table called products with columns product_id prodcut_name prodcut_price( values like 1200,2000,3000,100)
I have table called stats . In am inserting yes or no in the
I have a table called OffDays, where weekends and holiday dates are kept. I

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.