Need to search a range of dates based on a user's selection of a beginning and end? 2 Steps: Write the search string, and convert the date characters to ASCII. Here's the code!
STEP 1: On a search form in a query field, calc the search string. (In this example, INVOICE_DATE is the DATE field on the doc that needs to be in the range. StartDate and EndDate are fields on the Search form. Be sure that the field searched is a DATE. This will not work if the field is text. Also, be sure the date format used on the search form matches the stored format of the document.)
@If(StartDate!=""; "[INVOICE_DATE]>"+@Text(@Adjust(StartDate;0;0;-1;0;0;0))+"+AND+[INVOICE_DATE]<"+@Text(@Adjust(EndDate;0;0;1;0;0;0)); "");
STEP 2: Convert non URL characters to ASCII (i.e. /," ")
asciiString:=@ReplaceSubstring(@LowerCase(string); " ":""":"#":"$":"&":"+":"/":":":";": "<":"=":">":"?":"@": "[":"\"; "%20":"%22":"%23":"%24": "%26":"%2B":"%2F":"%3A":"%3B": "%3C":"%3D":"%3E":"%3F":"%40": "%5B":"%5C"; @If(asciiString != ""; asciiString; "")
Your $$Return would have something like this: (SearchString is the field calculating the query in Step 1.)
viewPath+"?SearchView"+"&Query="+SearchString
NOTE: You may not use the greater than or equal to operator in a web search. You must seperate these out. In the case above, I adjust the dates by 1 day to include the days chosen in the range.
This was first published in September 2001