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 derfloh on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

How to use date varible from text field in the query?

Status
Not open for further replies.

longmatch

Programmer
Nov 1, 2001
406
I met a problem to use date format data in the user text input box. How can I refer the value in the textbox in my query. The value from the text input box should be a pure text. Do I need to convert into date format using cDATE? How to refer in the query.



<%
dim strQuery
dim objrs
dim startdate

startdate = CDate(Request.Form (&quot;startdate&quot;))
if Request.Form(&quot;startDate&quot;) <>&quot;&quot; then
strQuery = &quot;select * from FORM_ID_198163500 where DateOfProc = startdate&quot;
set objrs = server.CreateObject(&quot;ADODB.recordset&quot;)
objrs.Open strQuery, objconn, adOpenForwardOnly, adLockReadOnly, adocmdText
Response.Write recTotable(objrs)
end if
%>

this code works fine without where sentence.

Big thanks

Haijun
 
&quot;select * from FORM_ID_198163500 where DateOfProc = '&quot; & startdate & &quot;'&quot;

incase the startdate value with single quotes Errol Barratt
856-697-1593
New Jersey
 
If you are using Access, then you will need to enclose the date in hashes (#) without the single quotes.

Ladyhawk.
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top