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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 9, 20262026-06-09T06:43:07+00:00 2026-06-09T06:43:07+00:00

I have a search page, where the articles can be searched by date. The

  • 0

I have a search page, where the articles can be searched by date. The search criteria is only with month and year.
So whenever the month is selected and clicked “filter”
I take the start day of that month as “dtStartDate”
and end day of the month as “dtEndDate”

The Articles which has to searched also has
Effective Start date as “EffStartDate”
and Effective End date as “EffEndDate”

So what should be the condition if, Both these “EffStartDate” and “EffEndDate” falls inside
“dtStartDate” and “dtEndDate” ?

I gave a try with this, but the results are not correct,

If (EffStartDate >= dtStartDate & EffStartDate  <= dtEndDate) 

    //Do Something     

ElseIf (EffEndDate >= ddl_FromDate & EffEndDate <= dtEndDate.AddDays(1)) Then

    //Do Something

End If

Scenario :
Lets assume that there are two articles which are going to be searched using different dates.

Article - 1
EffStartDate = 11/7/2012
EffEndDate = 31/8/2012

Article - 2
EffStartDate = 1/7/2012 
EffEndDate = 28/9/2012 

Now, in my search page, when i search for the article between 1/07/2012 to 31/07/2012
I should see both the articles as result, because both the effstardate and effenddate somewhere
falls in between the dates used for search.
But now i see only Artilce – 1 as result. Why ?

  • 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-09T06:43:09+00:00Added an answer on June 9, 2026 at 6:43 am

    It’s clear to me from your example that the text of your criteria is wrong. The text of your criteria state that you only want to show an article if both the effective start and end dates fall within the date range… if the entire effective range of the article fits entirely within the search. But your example indicates that you want to show the article if any part of the date range fits within the range of search. An edit to clarify that would be helpful, but for now I will move forward assuming that the example is the correct interpretation.

    You also seem to be mixing language syntax from VB.Net and C# together. You can’t just mix syntax like that. The strongest influence in your code snippet seems to be VB.Net, so I’ll use that in my example.

    In VB.Net, you could write a condition that matches the example for your search like this:

    If       (EffStartDate >= dtStartDate AndAlso EffStartDate  < dtEndDate.AddDays(1)) _
      OrElse (EffEndDate >= dtStartDate AndAlso EffEndDate < dtEndDate.AddDays(1)) 
      OrElse (EffStartDate < dtEndDate.AddDays(1) AndAlso EffEndDate >= dtStartDate) Then
       '...
    End If
    

    I’m also concerned that you’re writing this code in an If block at all. If these dates are in a database, then the database is by far the best place to filter your results. If the data is elsewhere, then a linq-to-objects query of some type will likely yield both better performance and be shorter and easier to maintain.

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

Sidebar

Related Questions

i have a search page in my site, where user can search all the
We have OCRed thousands of pages of newspaper articles. The newspaper, issue, date, page
I have a search page which uses a simple ajax request to get new
I have a search page like <div class=> <input id=search-input type=text class=input-medium search-query span4>
I have a search page that if there is results in the list it
I have a search page with the following scenarios listed below. I was told
I have a search page on my MVC site that contains a list of
I have a search page where I would like to stop the user entering
I have a search page in which I am searching data by passing multiple
I have a search page and want to add some filters to it, my

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.