Dear All,
I want to get list of month + year between two dates and save in array,
and also how to to use array for date in x++
how to do this please help me
*This post is locked for comments
Dear All,
I want to get list of month + year between two dates and save in array,
and also how to to use array for date in x++
how to do this please help me
*This post is locked for comments
Above given job is not taking care of year.. Put the two dates in two different years and you will see results. You may try with following job.
static void YearMonthCombinations(Args _args) { //<variables for dialog and dates> Dialog dialog; DialogField dfFromDate,dfToDate; FromDate vFromDate; ToDate vToDate; date nextDate; //</variables for dialog and dates> //<variables for array> date DemoArray[]; int counterIndex; int outputCounter; //</variables for array> ; dialog = new Dialog("Year-Month Combinations"); dfFromDate = dialog.addField(extendedTypeStr(FromDate)); dfToDate = dialog.addField(extendedTypeStr(ToDate)); if(dialog.run()) { vFromDate = dfFromDate.value(); vToDate = dfToDate.value(); counterIndex = 1; nextDate = vFromDate; info(strFmt('Date: %1 Year:%2 Month%2',nextDate,year(nextDate),mthName(mthOfYr(nextDate)))); do { nextDate = dateMthFwd(nextDate,1); if(nextDate <= vToDate) { //info(strFmt('%1',nextDate)); //add value in array DemoArray[counterIndex] = nextDate; counterIndex++; } } while(nextDate <= vToDate); for(outputCounter=1; outputCounter<=counterIndex-1; outputCounter++) { info(strFmt('Date: %1 Year:%2 Month:%2',DemoArray[outputCounter],year(DemoArray[outputCounter]),mthName(mthOfYr(DemoArray[outputCounter])))); } } }
Dear azam,
The following is the code to get list of months between two dates, reply whether your requirements are satisfied or not.
static void Job21(Args _args)
{
str dateMonth[];
TransDate date1, date2;
int month1, month2, counter, i, cnt, y;
;
date1 = mkDate(1, 1, 2016);
date2 = mkDate(31, 11, 2016);
month1 = mthOfYr(date1);
month2 = mthOfYr(date2);
y = year(date1);
if(month2 > month1)
counter = month2 - month1;
else
counter = month1 - month2;
cnt = counter;
info(strFmt("%1 is year", y));
for( i = 1; i <=counter; i++)
{
dateMonth[i] = mthName(cnt);
info(strFmt("%1", dateMonth[i]));
cnt--;
}
}
Thanks and regards
Kamesh K
Stay up to date on forum activity by subscribing. You can also customize your in-app and email Notification settings across all subscriptions.
André Arnaud de Cal... 291,280 Super User 2024 Season 2
Martin Dráb 230,235 Most Valuable Professional
nmaenpaa 101,156