47
Views
5
Comments
Solved
Get actual month and year of previous 6 months
Question
Application Type
Reactive

Hi Community,

Edit/Added:

I have added a sample oml file. Inside, i have 2 aggregates - Products, Month

In the screen 'Previous6Months', i did not add any UI. I only fetch data from database, to combine the 2 aggregates which i had created.

Had added a new Attribute, Month_Year. This allows me to get the Month/Year for the product, which i think had solved part of my problem.

However, in my actual app, i need to do a count of the total items. Can i really combined this 2 requirements in a single aggregate, or there is a need to call the aggregate twice, 1 to fetch the total count, and 1 to group the items. Because eventually, i will be using Advanced Excel Forge, to create the populating the following table, so that i can create a chart


Apologise for suddenly adding in a lot more requirements. Thank you


Original Question:

I want to to get the actual month/year of the previous 6 months from current date. 

  • Example, if CurrDate is 6th March 2025, it should return the following,
    • Feb 2025
    • Jan 2025
    • Dec 2024
    • Nov 2024
    • Oct 2024
    • Sep 2024

I have a Month aggregate in my Entities, which shows the following values,


Does anybody knows how i can achieve my intended results? 

Thank you. 

GetPrevious6Months.oml
2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP
Solution

Hi,

You don't need an aggregate, you can built either a client or server action that appends the following 6 expressions to a output list parameter of time text:

  • FormatDateTime(AddMonths(CurrDate(), -1), "MMM yyyy")
  • FormatDateTime(AddMonths(CurrDate(), -2), "MMM yyyy")
  • FormatDateTime(AddMonths(CurrDate(), -3), "MMM yyyy")
  • FormatDateTime(AddMonths(CurrDate(), -4), "MMM yyyy")
  • FormatDateTime(AddMonths(CurrDate(), -5), "MMM yyyy")
  • FormatDateTime(AddMonths(CurrDate(), -6), "MMM yyyy")

See attached module.

 If you need this list just on screen use the Client action to save you a round trip to the server. You can load the list in a local screen variable on OnIntialize and then use it everywhere as source on your screen.

Regards,

Daniel

Last6MonthsDemo.oml
2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

If you want my sample actions to be more generic, you could have an input parameter NoOfMonths, and use a ForEach to append the number of months to the list.

btw. try to copy/paste your reply in chatgpt, the reply is pretty much what I shared in the OML.

2022-05-01 03-47-53
Jun Mun Chan

Hi Daniël,

Thank you for your reply. I want to said, i learn my lesson from the way i asked my question in the forum.

On hindsight, i thought i was struck with getting the previous 6 months, with the correct year. After posting my original question, i went back to work on this issue, and realise that i can get it by adding a new attribute to retrieve it. Reason why i only asked part of my question, was really because i thought after solving this part, i can work on the rest of the issues and requirements myself (Trying not to be spoon-fed also, part of my learning process)

But one thing leads to another...and my requirements can't be 'unlinked', need to address them together.

And the time needed to create my sample OML, so that i can illustrate things more clearly, so my edited question took some time for me to post.

So end up, the replies to my original question might have really solved the issue, but on the greater scale of things, it might not work.

Thanks!

2024-12-02 13-16-47
Vipin Yadav

Hi @Jun Mun Chan ,

Could you please share your OML file with me? I will review it and get back to you promptly. 

Thanks,

Vipin Yadav

2020-07-21 19-28-50
Rajat Agrawal
Champion

Hi @Jun Mun Chan,

Apply this filter and try:

AddMonths(CurrDate(),-6) <= CurrDateTime()


Hope this will help you!!


Regards,

Rajat

2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP
Solution

Hi,

You don't need an aggregate, you can built either a client or server action that appends the following 6 expressions to a output list parameter of time text:

  • FormatDateTime(AddMonths(CurrDate(), -1), "MMM yyyy")
  • FormatDateTime(AddMonths(CurrDate(), -2), "MMM yyyy")
  • FormatDateTime(AddMonths(CurrDate(), -3), "MMM yyyy")
  • FormatDateTime(AddMonths(CurrDate(), -4), "MMM yyyy")
  • FormatDateTime(AddMonths(CurrDate(), -5), "MMM yyyy")
  • FormatDateTime(AddMonths(CurrDate(), -6), "MMM yyyy")

See attached module.

 If you need this list just on screen use the Client action to save you a round trip to the server. You can load the list in a local screen variable on OnIntialize and then use it everywhere as source on your screen.

Regards,

Daniel

Last6MonthsDemo.oml
2024-07-05 14-16-55
Daniël Kuhlmann
 
MVP

If you want my sample actions to be more generic, you could have an input parameter NoOfMonths, and use a ForEach to append the number of months to the list.

btw. try to copy/paste your reply in chatgpt, the reply is pretty much what I shared in the OML.

2022-05-01 03-47-53
Jun Mun Chan

Hi Daniël,

Thank you for your reply. I want to said, i learn my lesson from the way i asked my question in the forum.

On hindsight, i thought i was struck with getting the previous 6 months, with the correct year. After posting my original question, i went back to work on this issue, and realise that i can get it by adding a new attribute to retrieve it. Reason why i only asked part of my question, was really because i thought after solving this part, i can work on the rest of the issues and requirements myself (Trying not to be spoon-fed also, part of my learning process)

But one thing leads to another...and my requirements can't be 'unlinked', need to address them together.

And the time needed to create my sample OML, so that i can illustrate things more clearly, so my edited question took some time for me to post.

So end up, the replies to my original question might have really solved the issue, but on the greater scale of things, it might not work.

Thanks!

Community GuidelinesBe kind and respectful, give credit to the original source of content, and search for duplicates before posting.