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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 3, 20262026-06-03T09:27:23+00:00 2026-06-03T09:27:23+00:00

I am getting the following error The conversion of a varchar data type to

  • 0

I am getting the following error “The conversion of a varchar data type to a datetime data type resulted in an out-of-range value.” and the date format is “DD/MM/YY”

    public DataSet GetSynchronizeDataForDLDocs(string date_pushed)
{
    DataSet ds = new DataSet();
    string strQuery=string.Empty;

    if (date_pushed != null && date_pushed != string.Empty)                 // 105
         strQuery = 
            @"select 
                a.DLNO,
                a.NAME,
                b.TOPSTRING,
                Convert(datetime,a.DOB,103) as DOB,
                Convert(datetime,a.DOI,103) as DOI,
                Convert(datetime,b.datepushed,103) as datepushed 
            from 
                PLInfo_Demo a,
                DLInfo_Demo b 
            where 
                a.dlno=b.dlno 
            and
                Convert(DateTime,b.datepushed,103) > CONVERT(varchar,'" + date_pushed + @"' ,103)
            and 
                DATEPART(hh, b.datepushed) > Datepart(hh,'" + date_pushed + @"') 
            and
                DATEPART(MI, b.datepushed) > Datepart(MI,'" + date_pushed + @"' ) 
            and
                DATEPART(ss, b.datepushed) > Datepart(ss,'" + date_pushed + @"' ) 
            order by b.datepushed desc";
    else
         strQuery = @"
            select 
                a.DLNO,
                a.NAME,
                b.TOPSTRING,
                Convert(datetime,a.DOB,103) as DOB,
                Convert(datetime,a.DOI,103) as DOI,
                Convert(datetime,b.datepushed,103) as datepushed 
            from 
                PLInfo_Demo a,
                DLInfo_Demo b
            where 
                a.dlno=b.dlno ";
    ds = DbManager.ExecuteSalarData(
        strQuery, 
        CommandType.Text, 
        DbManager.strcon2, 
        null);

    return ds;
}
  • 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-03T09:27:25+00:00Added an answer on June 3, 2026 at 9:27 am

    First thing would be do not pass in date_pushed as a string. Parse it in your c# (DateTime.Parse or similar, perhaps specifying a format and culture), and pass it as a parameter. In all the places you have '" + date_pushed + '"', use @theParameter instead.

    The next thing is to store b.datepushed as a datetime – there should be no need to use convert on b.datepushed. If it is a string you are doing it wrong.

    After that, you are comparing a datetime field to a datetime parameter, which will work without issue. For example:

    and Convert(DateTime,b.datepushed,103) > CONVERT(varchar,'" + date_pushed + @"' ,103)
    

    becomes

    and b.datepushed > @date_pushed
    

    where b.datepushed is the datetime field, and @date_pushed is the datetime parameter. You can of course use DATEPART etc with a datetime – the important point is: it isn’t parsing anything at all.

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

Sidebar

Related Questions

I am getting the following error: Conversion failed when converting the varchar value '2010-01-10'
i'm trying to convert following varchar date to datetime format but it doesn't work
I'm getting an error message: unimplemented or unreasonable conversion requested using the following code:
Getting error with the following code: import java.util.Scanner; public class FahrenheitToCelsius{ public static void
I'm getting the following InvalidOperationException: The parameter conversion from type 'System.String' to type 'System.Runtime.Serialization.ExtensionDataObject'
I am getting following error error: invalid conversion from ‘const int*’ to ‘int*’ Following
I am getting the following error: Cannot implicitly convert type 'System.Collections.Generic.IEnumerable' to 'System.Collections.Generic.List'. An
Hi I am getting an error 'Conversion failed when converting date and/or time from
Am getting following error message on calling WCF service: The formatter threw an exception
I am getting following error with PHP 5.1.6: Fatal error: Declaration of Tl1Telnet::ExecuteCommand() must

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.