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

  • Home
  • SEARCH
  • 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 8300135
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 8, 20262026-06-08T16:26:04+00:00 2026-06-08T16:26:04+00:00

I have a view where I have a column having date in varchar formet

  • 0

I have a view where I have a column having date in varchar formet and in dd/MM/yyyy
when I tried to use order by it gives error that

Msg 241, Level 16, State 1, Line 2 Conversion failed when converting
date and/or time from character string.

The query is

select * from test1.dbo.abcd order by CONVERT(date,ddate,103)

Some dates on which it return 0 is 13/01/2010

18/12/2009
20/10/2009
21/06/2010
19/10/2009
18/11/2010
29/10/2009
29/10/2009
18/03/2010
15/03/2010
15/03/2010
15/03/2010
15/04/2010
15/04/2010
15/04/2010
15/04/2010
30/03/2010
14/05/2010
14/01/2010
23/10/2009
20/10/2009
27/10/2009
27/10/2009
20/07/2009
20/04/2010
13/08/2010
30/06/2011
23/07/2010
27/08/2010
24/09/2010

Can any one tell me why its returning 0 and how to sort it?

  • 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-08T16:26:05+00:00Added an answer on June 8, 2026 at 4:26 pm

    Since this works fine for me:

    SELECT CONVERT(date,'13/01/2010',103);
    

    Try:

    ORDER BY CONVERT(DATE, LEFT(ddate, 10), 103);
    

    What I suspect has happened is that the data pushed into your view has trailing characters that you can’t see (e.g. carriage returns) or non-printing characters. You can check for values that exceed 10 characters by:

    SELECT ... WHERE LEN(ddate) > 10
    

    If that still doesn’t work, then perhaps the data really is bad, e.g. maybe it is:

    13/O1/2010
    

    In which case the only thing you can really do is push back on the owners of the table/view to get correct data in the first place, or try to filter out using:

    SET DATEFORMAT DMY;
    
    ...
    WHERE ISDATE(ddate) = 1
    

    As for the title in your question, ISDATE returns 0 in that case because by default that’s not a date – in most cases SQL Server is set up using US English and a date format of MDY, therefore it expects date strings in the format mm/dd/yyyy. 13/01/2010 is the first day of the 13th month in 2010. My memory is sketchy but I am certain there wasn’t a 13th month that year.

    As others have suggested, the real fix for this is to store your data as date/time, not strings, and to pass in string literals in an unambiguous format, e.g. YYYYMMDD.

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

Sidebar

Related Questions

i have to show 3 columns in List view. I tried having table inside
I have a view that has a column to make it sortable. When clicking
We have a custom list that has a column called Connection Date and need
I have a list view comprised of the following: // Add column headers for
I have a GridControl view which is being populated with one column as a
We have a partitioned view with 12 member tables. The partitioning column is a
I have a listview <ListView Name=listView2> <ListView.View> <GridView> <!-- First Column --> <GridViewColumn Width=105
I have a grid view that has two simple columns, a report number and
Trying to use FNH to map a view - FNH insists on having a
Grid View Data Bind i have a database table with 4 columns having data

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.