HighDots Forums  

Searching a database

Macromedia Dreamweaver Macromedia Dreamweaver Discussions (macromedia.dreamweaver)


Discuss Searching a database in the Macromedia Dreamweaver forum.



Reply
 
Thread Tools Display Modes
  #11  
Old   
cmbergin
 
Posts: n/a

Default Re: Searching a database - 07-09-2004 , 11:19 AM






You can't say
Dim myVariable = something

You have to say
Dim myVariable
myVariable = something

You can just shove the code on top of your recordset code. Don't worry about
<% %>. As long as your code is between them, it's okay. Never will your code
be affected based on whether it's in its own set or not. Well, that's not
entirely true, but the situations are exceedingly rare (there's a certain
If..Then syntax I'm thinking of).


Reply With Quote
  #12  
Old   
aDAMFOX
 
Posts: n/a

Default Re: Searching a database - 07-09-2004 , 06:30 PM






Thanks,

I understand now about declaring variables

It is giving a different error now though

Syntax error converting datetime from character string.

/adv_search_results.asp, line 67


Could i maybe do this instead

get value form user via a dropdown menu so if they want to seadcrh by
yesterdays dates they select 1 or day before that select 2 then send to
variable Get_User_date

so we say
dim Get_User_date
dim Value_to_serarch

if Get_User_Date = 1 then
Value_to_search = <%=DateAdd ("d", -1, Date())%>
else if Get_User_Date = 2 then
Value_to_search = <%=DateAdd ("d", -2, Date())%>
etc..........

myDateVariable =
Month(Value_to_search)&"/"&Day(Value_to_search)&"/"&Year(Value_to_search)

so its getting date when it is still in Datetime format and not a character
String from variable Value_to_search.

If this can be done is the Month(Value_to_search) syntax correct or does it
need ?? or ?? with it.

Thanks for being patient with a very slow learner.
Adam



Reply With Quote
  #13  
Old   
cmbergin
 
Posts: n/a

Default Re: Searching a database - 07-12-2004 , 11:43 AM



Your syntax is correct, but we can make it even better. Also, since
Get_User_Date is from a form, you'll have to convert it first.

Dim DaysAgo
Dim UserDate
Dim SearchDate

DaysAgo = CInt(Request.Form("numDaysAgo"))
UserDate = DateAdd("d",-1*DaysAgo, Date())
SearchDate = Month(UserDate)&"/"&Day(UserDate)&"/"&Year(UserDate)

Now, your variable SearchDate is ready to go! You can use it in your query
normally:

xxx.Source = " <a whole bunch of stuff> WHERE InDate >= ' "&SearchDate&" ' "





Reply With Quote
Reply




Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off



Powered by vBulletin Version 3.5.4
Copyright ©2000 - 2009, Jelsoft Enterprises Ltd.