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

Latest Axapta / Dynamics AX FAQ Pages

Get our Free Newletter

Don't you have the time to be online here at DUG every day? So how do you follow what is going on in the Dynamics industry and community?
If you subscribe to the DUG Newsletter then you can relax! We will make sure that you don't miss the big news!

Check out our
Newsletter Subscription Center
page a complete list of our different newsletters.

Solution (Not Verified) This post has 0 verified solutions | 4 Replies | 1 Follower

25 Posts
200 Points
Joined: 2012-7-19
Last Online:
2012-10-9 8:40
Location: Chennai
Akshay Bankar posted on 2012-9-13 15:34

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??

All Replies

Male
363 Posts
7,570 Points
Joined: 2010-8-23
Last Online:
2013-5-13 15:08
Location: Bangalore,India
Suggested by Pranav

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));

}

25 Posts
200 Points
Joined: 2012-7-19
Last Online:
2012-10-9 8:40
Location: Chennai
Akshay Bankar replied on 2012-9-20 13:51

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.

25 Posts
200 Points
Joined: 2012-7-19
Last Online:
2012-10-9 8:40
Location: Chennai
Akshay Bankar replied on 2012-9-24 7:27

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.

Male
363 Posts
7,570 Points
Joined: 2010-8-23
Last Online:
2013-5-13 15:08
Location: Bangalore,India

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 <tableName>.<fieldName>. That will get you the date value from the table.If any prob.let me know.

 

Page 1 of 1 (5 items) | Get this RSS feed | Bookmark and Share