How to select the data for privious week, next week, Current week.?

I develop a form, in that form 3 buttons are their-----

PREVIOUS WEEK,

CURRENT WEEK,

NEXT WEEK.

this are 3 buttons, If I click on PREVIOUS WEEK button then from Monday to saturday of last week data should come, same if I click on NEXT WEEK then from monday to saturday of next week data should come. same as for CURRENT WEEK,

How can I write code for this??

Hello Akshay,

Try this…you get the dates of current,previous and next week dates by using this logic…below is the job gives the logic to gets the dates of current,previous and next weeks dates.

static void Example_date(Args _args)

{

TransDate cwkstartDate,cwkEndDate;

TransDate lwkstartDate,lwkEndDate;

TransDate nwkstartDate,nwkEndDate;

TransDate d;

;

d = systemDateget();

cwkstartDate = Global::dateStartWk(d);

cwkEndDate = Global::dateEndWk(d) - 1;

info(strfmt(“Current StartDate: %1 and EndDate: %2”,cwkstartDate,cwkEndDate));

lwkstartDate = (Global::dateStartWk(d) - 7);

lwkEndDate = (Global::dateEndWk(lwkstartDate)) - 1;

info(strfmt(“Lastweek StartDate: %1 and EndDate: %2”,lwkstartDate,lwkEndDate));

nwkstartDate = (Global::dateStartWk(d) + 7);

nwkEndDate = (Global::dateEndWk(nwkstartDate)) - 1;

info(strfmt(“Nextweek StartDate: %1 and EndDate: %2”,nwkstartDate,nwkEndDate));

}

Hi naresh,

Thanks for your reply,

I used this code, it is working finely.

Here we are compairing the systemdate “d = systemdateget();”

but as per requirement I nedd to compaire it from Dynamics AX date. means whatever startdate we set in calender of Dynamics AX it should compaire from that. Can you tell me how can I do this.

Hi Naresh,

Your code is working finely, but as per requirement I want to compaire dates from the AOS date.

Means,

in Organization administration-Area page-Common-Calendars-DateDimensions

here if I select the start day of week as Thursday then that button For previous week, next week and current week should work for that start day not from system date.

Hello Akshay,

Check in which table the date is coming from. So take the date from that table i.e. instead of systemdateget() in the above code take the date from that table as .. That will get you the date value from the table.If any prob.let me know.