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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 7, 20262026-06-07T15:00:59+00:00 2026-06-07T15:00:59+00:00

I have a form in asp with two text boxes. If user enters a

  • 0

I have a form in asp with two text boxes. If user enters a value in it and submit, it displays data from MS access query for the selected dates by user. If users just leave both text boxes blanks, I want to display complete output from the database.
This is my sample query in access :

select column_date, field1, field2, sum(field3) from table1
where field1 like '*xyz' and 
column_date between [@startdate] and [@enddate]
group by column_date, field1, field2

My asp codes are similar to below :

objCmd.CommandText = "Query"
objCmd.CommandType = adCmdStoredProc
Set objParam = objCmd.CreateParameter("@startdate" , adInteger, adParamInput, 0, 0)
objCmd.Parameters.Append objParam
Set objParam = objCmd.CreateParameter("@enddate" , adInteger, adParamInput, 0, 0)
objCmd.Parameters.Append objParam
if request.form ("startdate") = "" Then
objCmd.Parameters ("@startdate") = 1
Else
objCmd.Parameters("@startdate") = request.form("startdate")
objCmd.Parameters("@enddate") = request.form("enddate")
End if
if request.form ("enddate") = "" Then
objCmd.Parameters ("@enddate") = 31
Else
objCmd.Parameters("@startdate") = request.form("startdate")
objCmd.Parameters("@enddate") = request.form("enddate")
End if
................

Please note my startdate and enddates are text datatype with just numbers e.g. 1, 2, 3, 4, 5 ( 1 means 1st July 2012, 2 means 2nd July 2012)

I have two text boxes name “startdate” and “enddate”. When user enters dates in the boxes, it returns data between the two dates from the query. If user leaves blank, it shows error.

But I want to make sure if user leave both text boxes blank, it returns all values from the query. If user input a single value in any of the two text boxes, it should return data only for that date.

I’m not sure how can I achieve 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-07T15:01:00+00:00Added an answer on June 7, 2026 at 3:01 pm

    You say

    “Please note my startdate and enddates are text datatype with just numbers e.g. 1, 2, 3, 4, 5. (1 means 1st July 2012, 2 means 2nd July 2012 and so on).”

    Which suggests that the date cannot be less than 1 or greater than 31. Can you do some pre-processing on your dates?

    If the first date is null and the second date is null, then the “dates” should be 1 and 31.
    If either of the two dates is null but the other is not null, the “dates” should be equal to each other.

    Pseudo code:

    If IsNull(firstdate) Then
        If IsNull(seconddate)
            firstdate=1
            seconddate=31
        Else
            firstdate=seconddate
        End If
    End If
    
    If IsNull(seconddate) Then
       seconddate=firstdate
    End If
    

    This would give you :

    BETWEEN 1 And 31 '' All
    

    And, say

    BETWEEN 2 And 2 ''A single day
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have a simple in VB/ASP.NET form containing two text boxes, I am attempting
Using ASP.NET VB, I have a form with some text boxes and a Gridview.
Overview: I have two text boxes at the top of this form for inputting
In my form i have two text boxes txtName & txtAge . I use
I have an ASP.NET form for currency exchange requests. There are two text fields
I have got two buttons, which both submit a form in asp.net. I need
I am using Asp.net dropdownlist in one of my form ..I have two dropdown
I have a form within an ASP.NET MVC application and I'm trying to submit
I am trying to insert from code behind on an asp.net form, I have
I have two buttons. Both buttons have two attributes – data-from and data-to. When

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.