web
You’re offline. This is a read only version of the page.
close
Skip to main content
Community site session details

Community site session details

Session Id :
Microsoft Dynamics AX (Archived)

get records by selected month

(0) ShareShare
ReportReport
Posted on by 1,295

Hi,

I would like to know how to get the records by month from 1st day to last day of the month only (for example in inventtrans I want to get the records based from date Financial,

can you please give me some ways how to get it? because I already created one (i choose June but its getting all the data from june till december of this year)

my code:

 while select forupdate inventTrans where closingsumdateselected <= inventTrans.DateFinancial  &&  inventTrans.DateFinancial >= closingsumdateselected

hoping for your prompt response. thank you

*This post is locked for comments

I have the same question (0)
  • Ali Zaidi Profile Picture
    4,657 on at
    RE: get records by selected month

    Hi Ivan, you have to create two utcDatetime and then query on InventTrans

    following code snippet possible helps you to solve your problem

    startdate =mkdate(Day_number, Month_number, Years_Number);

    EndDate =mkdate(Day_number, Month_number, Years_Number);

    _UtcStartPeriod =  DateTimeUtil::newDateTime(startdate,0);

    _UtcEndPeriod = DateTimeUtil::newDateTime(EndDate,86400);

    while select * from inventTrans where  inventTrans.DateFinancial > _UtcStartPeriod  &&  inventTrans.DateFinancial <= _UtcEndPeriod

  • SII1MNL Profile Picture
    1,295 on at
    RE: get records by selected month

    7585.Untitled3.jpg

    Hi,

    I created this form the calculation will be based from month only (July1- July30). 

  • Mea_ Profile Picture
    60,284 on at
    RE: get records by selected month

    And what is the question ?

  • SII1MNL Profile Picture
    1,295 on at
    RE: get records by selected month

    how to get records based from month?  the form I created above is only  by month so meaning July1-31 only. Do I need to use datefrom,dateto?

  • Suggested answer
    Mea_ Profile Picture
    60,284 on at
    RE: get records by selected month

    You want to show on this form records only from current month ?

    If yes you need to add range on a query.

    You can override init method of the form and do something like:

    element.query().dataSourceTable(tableNum(MyTable)).addRange(fieldnum(MyTable, MyDate)).value(SysQUery::range(fromDate, toDate));

  • SII1MNL Profile Picture
    1,295 on at
    RE: get records by selected month

    because on the form is only month and year no specific from date - to date. when I select june and calculate starting from june 1-30.

  • Verified answer
    SII1MNL Profile Picture
    1,295 on at
    RE: get records by selected month

    I found the solution already. I used endmth method to get the end of the month. Thank you for your help. :)

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Responsible AI policies

As AI tools become more common, we’re introducing a Responsible AI Use…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans