View Single Post
Old 07-14-2004, 08:53 AM   #1 (permalink)
Devil's Angel
Inactive
 
Join Date: 10-13-03
Location: Nova Scotia, Canada
Posts: 63
iTrader: 0 / 0%
Latest Blog:
None

Devil's Angel is liked by many
Send a message via ICQ to Devil's Angel Send a message via MSN to Devil's Angel
SQL Syntax for Like

Hey everyone!

This is probably a realy easy fix that I'm overlooking. I always mess up the syntax for SQL.

I'm trying to do a like on a date field.

On one page I have the user select a month which is in a querystring. The next page takes the string and changes it slightly so I can compare it to a date field in my database. My code:

Month = QueryString("Month")

If Month = "1" Then
Month = "1%"
End If

I make it change to 1% because to do a like you add % after so it looks for everything that starts with 1.

sql = "SELECT select bunch of fields including date of publication WHERE [News-Clippings-Information].[Date of Publication] LIKE 'Month' "

Now this doesn't output anything....the Month variable does output 1% if I just call <%=Month%>

If I use the same statement above but replace 'Month' with '1%' it works fine. So I tried just Month...error...I tried "Month"....error...I tried a whole bunch more...still error.

I'm sure it's just a small stupid syntax error...but if someone could point it out I would much appreciate it!
Devil's Angel is offline   Reply With Quote