Skip to main content



No record found.

Microsoft Dynamics AX forum
Suggested answer

getting year from Accounting Date

Posted on by 2,016

Greeting everyone 

i'm trying to get year and comparing 

select sum(TransactionCurrencyAmount) from generalJournalAccountEntry2 where generalJournalAccountEntry2.MainAccount==MainAccount::findByMainAccountId(_mainAccount).RecId
        join generalJournalEntry where generalJournalEntry.RecId == generalJournalAccountEntry2.generalJournalEntry
        && year(generalJournalEntry.AccountingDate) ==year(fromDate)
        join ledger where ledger.RecId==generalJournalEntry.Ledger && ledger.Name==companyListIterator2.value()
        join fiscalCalendarPeriod where fiscalCalendarPeriod.RecId == generalJournalEntry.FiscalCalendarPeriod
        && fiscalCalendarPeriod.Type==FiscalPeriodType::Opening;


how can i solve that?!

  • Suggested answer
    Martin Dráb Profile Picture
    Martin Dráb 225,549 Super User on at
    RE: getting year from Accounting Date

    I would get dates for the beginning and the end of the year and compare the date with them. For example:

    int year = year(fromDate);
    select ...
    	&& generalJournalEntry.AccountingDate >= mkDate(1, 1, year)
    	&& generalJournalEntry.AccountingDate < mkDate(1, 1, year   1)

Helpful resources

Quick Links

Replay now available! Dynamics 365 Community Call (CRM Edition)

Catch up on the first D365 Community Call held on 7/10

Community Spotlight of the Month

Kudos to Saurav Dhyani!

Congratulations to the June Top 10 community leaders!

These stars go above and beyond . . .


André Arnaud de Calavon Profile Picture

André Arnaud de Cal... 287,914 Super User

Martin Dráb Profile Picture

Martin Dráb 225,549 Super User

nmaenpaa Profile Picture

nmaenpaa 101,148


Featured topics

Product updates

Dynamics 365 release plans