HI All
I have an requirement like
-
User will enter the Date Manually in the StartDate Field.
-
After that he will enter the No of Months in Eff Months field.
-
In Enddate filed should update automatically based on the start date.
ex:
Start date is assume Today :(i.e 05-03-2012)
Eff month is :3
End date should upadate as :16-06-2012(Automatically).
Can any one help me how to achive this functionality.
Harish
2
You can use standard functions such as nextMth, nextQtr, nextYr etc.
You can also use calendar functionality for this purpose. Small code below -
static void testCalendar(Args _args)
{
WorkCalendarDate WorkCalendarDate;
int noOfDays;
;
while select WorkCalendarDate
{
if (year(WorkCalendarDate.TransDate) == 2012
&& mthOfYr(WorkCalendarDate.transDate) == 3)
{
noOfDays++;
}
}
info(strFmt(‘No of days in March 2012 is %1’, noOfDays));
HI
I got the solution,
Form Methods
Transdate calcDate(TransDate _effDate,
int _months,
int _days)
{
int counter = 1;
int mm, dd, yy;
TransDate tmpDate;
;
tmpdate = _effdate;
while (counter <= _months)
{
_effDate = nextMth(_effDate);
Counter ++;
}
mm = mthofyr(_effdate);
yy = year(_effDate);
dd = dayofMth(tmpdate);
_effDate = mkdate(dd, mm, yy) + _days;
return (_effDate - 1);
}
in the FormDatasource-EffMonths field i have called my method.
TblName.Enddate = element.calcDate(TblName.StartDate,TblName.EffMonths,0);
TblName_ds.executeQuery();