Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Westi on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Query 2

Status
Not open for further replies.

sera

Technical User
Jun 29, 2000
360
US
Hello all,
I am trying to set up an ASP page that will allow the user to query by year. The date format is mm/dd/yy. The database is Access2000. I have an input field that allows the user to enter a year. I would like to be able to query the dates for the year entered and return all dates that match that year. Any help would be appreciated. If this post needs more clarification please let me know. Sera
I often believe that...
My computer is possessed!
 
Well, you could do something like this:

Dim fromDate, toDate, SQL

fromDate = "01/01/" & yearSelected
toDate = "12/31/" & yearSelected

SQL = "SELECT * FROM Table WHERE theDate BETWEEN #" & fromDate & "# AND #" & toDate & "# ORDER BY theDate"
 
&quot;SELECT * FROM tablename WHERE datefield > #12/31/&quot; & Request.Form(&quot;txtYear&quot;) - 1 & &quot;# AND datefield < #1/1/&quot; & Request.Form(&quot;txtYear&quot;) + 1 & &quot;#&quot;

Basically select everything from your table called tablename where the date field named datefield is between dec 31 of the year before the user entry and jan 1 of the year after the user entry.
There are quite a few ways to do this, (like using SQL between keywords, and contains keywords) but this ought to work.
-Tarwn ------------ My Little Dictionary ---------
Reverse Engineering - The expensive solution to not paying for proper documentation
 
Thank you both. I am not thinking very clearly today. I really appreciate the help. I don't know why I did not think to do this....
Sera
I often believe that...
My computer is possessed!
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top