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)
  • 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. :)

  • 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.

  • 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

    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?

  • 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

    7585.Untitled3.jpg

    Hi,

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

  • Ali Zaidi Profile Picture
    4,655 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

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…

Abhilash Warrier – Community Spotlight

We are honored to recognize Abhilash Warrier as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

#1
Martin Dráb Profile Picture

Martin Dráb 2 Most Valuable Professional

#1
Guy Terry Profile Picture

Guy Terry 2 Moderator

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans