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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 23, 20262026-05-23T00:10:20+00:00 2026-05-23T00:10:20+00:00

I am developing one web application using asp.net 2005 and Microsoft SQL Server 2008

  • 0

I am developing one web application using asp.net 2005 and Microsoft SQL Server 2008. I need a help for fetching the data from database between a given range.

the date field in my table is of type VARCHAR(25) and the date format stored is dd-mm-yyyy. when I using the between clause in the SQL query then it is not giving all the data i.e. the date criteria in where clause is not working fine.

while my clients requirement is to keep the date format as dd-mm-yyyy and fetch the data according to the given range.

so please help me out with that what should I do in this case.

SQL query :

@datefrom varchar(15),  // parameter in the procedure           
@dateto varchar(15) 

set @sql = '';     
set @sql = @sql +  'SELECT * FROM ven_timesheetreportmaster vtsrm WITH (nolock)    
                    INNER JOIN ven_descriptionmaster_timesheet vdmts ON vdmts.description_id = vtsrm.description_id '  
set  @sql  = @sql +  ' WHERE vtsrm.entry_date BETWEEN ''' + @datefrom + ''' AND  ''' + @dateto  + '''  '

if ( @emp_id !='0')    
    set  @sql  = @sql +  ' AND vtsrm.emp_id =' + @emp_id + ' '  

In the ven_timesheetreportmaster table, the entry_date is a varchar datatype..

If I pass values ,

@date from : 01-05-2011
@date to : 31-05-2011

it showing me all the values in the db from april to till date

  • 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-23T00:10:20+00:00Added an answer on May 23, 2026 at 12:10 am

    You have a string comparison on the varchar(25), not a date comparison so exactly as expected. That is, the string ’06-06-2011′ is before the string ’31-05-2011′

    Add some CONVERTs with style 112 and compare actual dates.

    Or fix your data… the format dd-mm-yyyy should be set in the client code and the database should be native date/time types.

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

Sidebar

Related Questions

I'm developing an web application using asp.net mvc, and i need to do a
I am developing a C#/SQL ASP.NET web application in VS 2008. Currently I am
When developing a web application using ASP.NET, do you have any hints about how
i'm new to asp.net.. i'm developing a web application using asp.net a jquery. i
I am developing an ASP.Net web application. Some of my users' browsers are rendering
I am developing one chart application on .net framework by using Silverlight and Visifire,
I am developing a new web application from scratch. I need to provide multi-language
We are developing a web application, and one of or major concerns are about
I am developing iPhone application and In that application I've one TableViewController , and
What are profound advantages that one get when using COM for developing components over

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.