Skip to main content

Notifications

Announcements

No record found.

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

  • Verified answer
    SII1MNL Profile Picture
    SII1MNL 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
    SII1MNL 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
    Mea_ 60,278 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
    SII1MNL 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
    Mea_ 60,278 on at
    RE: get records by selected month

    And what is the question ?

  • SII1MNL Profile Picture
    SII1MNL 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
    Ali Zaidi 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

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

December Spotlight Star - Muhammad Affan

Congratulations to a top community star!

Top 10 leaders for November!

Congratulations to our November super stars!

Tips for Writing Effective Verified Answers

Best practices for providing successful forum answers ✍️

Leaderboard

#1
André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 291,431 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,503 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans