setrange between two year

vyankuvyanku Member Posts: 791
I create report . i want to show the sum of payble amount within 6 month.
I have values like 1 ,2,3.... in Month field in the table.
So I create veiable smonth and emonth for starting date and ending date respectively. and syear and eyear for starting year and ending year.
when I run the report for date 01-04-07 to 01-09-07. it will calculate amount from another year also as I write setrange for month and in 07 and 08 both years have 4th month.
So I write setrange for year also.
But now when I insert dates like 01-09-07 to 01-03-08 it will not calculate the amount as there is setrange for year.
On Pre data Item
payemppaydet.SETFILTER("Pay Element Code",'ESI');
 smon := DATE2DMY(startdate,2) ;
 emon :=  DATE2DMY(enddate,2) ;
 syear := DATE2DMY(startdate,3) ;
 eyear := DATE2DMY(enddate,3) ;
payemppaydet.SETRANGE(payemppaydet.Month,smon,emon);
payemppaydet.SETRANGE(payemppaydet.year,syear,eyear);
Employee - OnAfterGetRecord()
payemppaydet.SETRANGE(payemppaydet."Employee No","No.");
    payemppaydet.CALCSUMS("Payable Amount");
    esiamt := payemppaydet."Payable Amount";

What can i do to solve this problem??
please suggest..

Answers

  • flfl Member Posts: 184
    It seems to me you have a bad design of the table. Why didn't you use a normal date field? The design you made by separate day, month and years fields is good for pivot tables. But by using a normal date in navision for every record, you could filter very easy.

    payemppaydet.SETRANGE(payemppaydet.PostingDate,startdate,calcdate('+6M-1D',startdate));
    Francois
    Consultant-Developper

    http://www.CreaChain.com
  • NRNR Member Posts: 78
    By using a date record variable, you can filter on the year and Period start fields.
  • vyankuvyanku Member Posts: 791
    Thanks FL it solves my problem.
    Thanks for solution.
Sign In or Register to comment.