Gossamer Forum
Home : Products : DBMan : Installation :

limit hits when using "-gt"-searches

Quote Reply
limit hits when using "-gt"-searches
How do I limit the number of hits when using a "greater than" search?
I tried the "mh=7" but it doesnot work.
My searchstring looks like this:
dbman.cgi?db=hsferie&Dato=>01-maj-1999&sb=1&mh=7&uid=default&view_records=1

the searchstring is put togehter by a function from values of dropdownboxes, and I must have ">" at that position, cannot use -gt. ("illegal date format")
Quote Reply
Re: limit hits when using "-gt"-searches In reply to
Regarding the problem with "-gt" searches on dates, I think it's a bug. Make the following changes in db.cgi -- sub query:

Code:
if ($in{"$column-gt"} !~ /^\s*$/) {
($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-gt"})
or return "Invalid date format: '$in{$column}'");
push(@search_gt_fields, $i); }
if ($in{"$column-lt"} !~ /^\s*$/) {
($db_sort{$column} eq 'date') and (&date_to_unix($in{"$column-lt"})
or return "Invalid date format: '$in{$column}'");
push(@search_lt_fields, $i); }

I don't know why setting mh doesn't work for you.

Wish I could be of more help.


------------------
JPD
Quote Reply
Re: limit hits when using "-gt"-searches In reply to
Thank you VERY much.

I can now do the "-gt" search (and -lt)
BUT still &mh=7 is not working.
I can limit the search now, however, by using a -lt statement, but I do not want to make a routine for adding 7 days to a date in this format, as I must change name of month and year.

How do I add 7 days to do a limiting -lt-search?

I now use this string for searching:

dbman.cgi?db=hsferie&Dato-gt=01-maj-1999&Dato-lt=08-maj-1999&sb=1&mh=7&uid=default&view_records=1

(the sb=1 is the Dato-field)
Quote Reply
Re: limit hits when using "-gt"-searches In reply to
Thank you VERY much.

I can now do the "-gt" search (and -lt)
BUT still &mh=7 is not working.
I can limit the search now, however, by using a -lt statement, but I do not want to make a routine for adding 7 days to a date in this format, as I must change name of month and year.

How do I add 7 days to do a limiting -lt-search?

I now use this string for searching:

dbman.cgi?db=hsferie&Dato-gt=01-maj-1999&Dato-lt=08-maj-1999&sb=1&mh=7&uid=default&view_records=1

(the sb=1 is the Dato-field)
Quote Reply
Re: limit hits when using "-gt"-searches In reply to
I'm not sure I'm understanding you. The "mh" is used to limit the number of records returned. From your last post it seems you want to limit the range of dates that are returned. That's not too hard, but you can't use "mh" for it.

How are you determining the "Dato-gt" date? I need to know that in order to be able to figure out how to determine the "Dato-lt" date.


------------------
JPD
Quote Reply
Re: limit hits when using "-gt"-searches In reply to
The time has come for an URL:
http://www.familieferiebornholm.dk/bookinf/

that will say more tahn many word here.

Actually at this point I could use just a "-gt" search IF only I can get that search to be a "greater than OR equal to" as I need to return a list starting on the day chosen and showing records 7 days after that.
I could set the values of the dropdown options to one less, but then I get in trouble when the value "1" is chosen.

I am considering changing the whole thing to calculate the number of the day in the year, as I have the ID to show 1999-365.
By the way ID-gt searches doesnot work on that, probably because of the dash?
Maybe I just have to hex the dash?


Quote Reply
Re: limit hits when using "-gt"-searches In reply to
I was able to figure out what you were doing by looking at the site -- even though I don't know Danish! Smile Well, sorta. I don't know Java and I don't use frames much, but I think I've got the general idea. Somewhere you're converting the three select fields into one date field, right? And that must be in db.cgi, probably in the query subroutine.

If I'm right about that, to get it to start with the date entered and retrieve records with dates after that, you can use (in sub query):

Code:
$in{'Dato-gt'} = &get_date(&date_to_unix($in{'Dato'}) - 86400);

If you want to include dates that are 7 days after the date entered, add

Code:
$in{'Dato-lt'} = $get_date($date_to_unix($in{'Dato'}) + 691200);

This will give you a range starting with the date entered and including the 7th day after it. If you only want to include only the 6th day after it, change the 691200 to 604800. You'll probably want to experiment with the numbers until you get the results you want. Just use 86400 multiplied by the number of days.

------------------
JPD


[This message has been edited by JPDeni (edited February 11, 1999).]
Quote Reply
Re: limit hits when using "-gt"-searches In reply to
Danish? isnīt that something you eat? :-)
Yes , I am converting the select fields at the users machine before sending the string to the server. So this is sent:
db.cgi?db=hsferie&Dato=07-jul-1999&sb=1&mh=7&uid=default&view_records=1

Tried also &Dato-gt &Dato-lt combo. No luck.

I have been trying to put the code into the "sub query", but I get a server error, already at calling db.cgi


Very interesting with that date_to_unix ; must look up what these numbers represent.
Quote Reply
Re: limit hits when using "-gt"-searches In reply to
Well the server error was just because of a syntax error in the:
$in{'Dato-lt'} = $get_date($date_to_unix($in{'Dato'}) + 691200);

Should be &get_date(&date_to_unix($in{'Dato'}) + 691200);

The first string you gave:
$in{'Dato-gt'} = &get_date(&date_to_unix($in{'Dato'}) - 86400);
worked , but showed tomorrows date as the first record, instead of the requested date.

I will try to experiment a little with the codestring you gave for $in{'Dato-gt'}



[This message has been edited by poulR (edited February 11, 1999).]
Quote Reply
Re: limit hits when using "-gt"-searches In reply to
Sorry about the typo. I start thinking of the whole thing and forget the little things. Smile

When you call &date_to_unix, you get the number of seconds between 1-Jan-1970 and the date that is passed to the subroutine. (Which is the reason another person is having problems searching by a date before 1970.) The number 86400 is the number of seconds in one day -- 60 x 60 x 24.

I'm not sure why folks are having problems with it. It works every time when I test it on my computer.

I have Perl on my home computer and I just tested the following:

Code:
$in{'Dato'} = "1-May-1999";
$in{'Dato-gt'} = &get_date(&date_to_unix($in{'Dato'}) - 86400);
$in{'Dato-lt'} = &get_date(&date_to_unix($in{'Dato'}) + 691200);
print "$in{'Dato-gt'}\n$in{'Dato-lt'}";

The result was

30-Apr-1999
09-May-1999

That is what you want, isn't it?

------------------
JPD


[This message has been edited by JPDeni (edited February 11, 1999).]
Quote Reply
Re: limit hits when using "-gt"-searches In reply to
Please see my post apologizing for misleading you and Jamie and others about the searches. I think if you use what I have there, you'll be all set.

Sorry!


------------------
JPD