Icon View Thread

The following is the text of the current message along with any replies.
Messages 1 to 1 of 1 total
Thread Need some help with this, Alarm with recurrence
Sat, Nov 10 2007 2:46 PMPermanent Link

"Luis M. Norberto"
I'm trying to find a record in a table with some alarms.  
The user chooses the day of month to be warned,
with the possibility to be warned several days before the final day
Until that day he will be warned

So :
Using datetimepicker1 to test dates.

Table1:
id, dia, diasmais: integer
mes1, mes2: datetime

example with sucess :
datetimepicker1 date = 2007-11-20
dia = 23
diasmais =4
mes1 = 2000-01-01
mes2 = 2010-12-31

(dia-diasmais) = 19 , ( 20 is between 19 and 23 )

Now without sucess  :
datetimepicker1 date = 2007-11-30
dia = 1
diasmais =4

Doenst work, because (dia-diasmais) =  -3

So , how can i solve this ?
I can change diasmais to datetime... or ... ?

Here the sql im using:
var
result:integer;
  begin
  With Query1 do begin
  Close;
  Sql.Clear;
  Sql.Add('Select id from Table1');
  Sql.Add('where '+Formatdatetime('dd',(datetimepicker1.Date))+' between
(dia-diasmais) and (Dia)');
  Sql.Add('and '+QuotedStr(AnsidateTostr(datetimepicker11.Date))+('
between mes1 and mes2'));
   execsql;
 end;

Result:=Query1.RecordID;

 if Result>0 then table1.Locate('ID',Result,[]);


Tnx for your time
Image