PDA

View Full Version : how i can search by date


bmwmpower
04-15-2003, 02:34 PM
i have data base and i want search by date
in my database the record for date
Dateadded = this is the format 23/03/2003

and this is my code

<select name="Dateadded">
<option value="<%=Request("Dateadded")%>"><%=Request("Dateadded")%></option>
<option value="">All</option>
<%
Do While Not myrecsource2.EOF
%>
<option value="<%=myrecsource2("Dateadded")%>"><%=myrecsource2("Dateadded")%></option>
<%
myrecsource2.MoveNext
Loop
%>
</select>

======================================
this is the code for search where the problem


If Not IsEmpty(Request("Dateadded")) Then
If IsNumeric(Request("Dateadded")) Then
'Add to query
'First item so we don't have to test for WHERE
blnWhere = True 'Set where to true
sql = sql & "WHERE "
sql = sql & "(Dateadded = " & CStr(CLng(Request("Dateadded"))) & ") "
End If
End If

khillabolt
04-15-2003, 03:27 PM
What kind of database are you using?

If my memory serves me right, and you are using Access, I believe you have to put "#" around dates. I haven't used Access in a long time (use SQL Server 2000 mostly), so I could be off base.

Ex:
sql = sql & "(Dateadded = #" & CStr(CLng(Request("Dateadded"))) & "#) "

I'm also curious why you are using the CStr, and CLng functions here. They don't seem neccessary to me.

HTH :thumbsup:

bmwmpower
04-15-2003, 03:51 PM
thanks
i tray this code
sql = sql & "(Dateadded = #"& Request("Dateadded")&"#) "
and it is okaaaaaaaaaaaaaaaaa


thanks

khillabolt
04-15-2003, 03:53 PM
Awesome, glad to help. :)