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)

Filter AOT query on number of years

(0) ShareShare
ReportReport
Posted on by 49

Hi, 
I'm working on a shortlisting process for recruitment. For this the requirement states that applicants be filtered on number of experience. 
The input is number of experience required.
The query is applied on HcmPersonProfessionalExperience
Following is the query

query      =   new Query();
qbds       =   query.addDataSource(tableNum(HcmPersonProfessionalExperience));
qbr        =   qbds.addRange(fieldNum(HcmPersonProfessionalExperience,StartDate));

qbr.value(strFmt('(%1 - %2) <= %3',
                fieldStr(HcmPersonProfessionalExperience, EndDate)  ,
                fieldStr(HcmPersonProfessionalExperience,StartDate), 5));

queryRun   =   new QueryRun (query);


This is code I started with. But this filters on number of days.
I tried using SysQueryUtilRange::YearRange , DatetimeUtil::year and year functions but it did not work.

The EndDate and StartDate are transdate
My question: can I filter the query on number of years equal to the experience required.

*This post is locked for comments

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    236,353 Most Valuable Professional on at
    RE: Filter AOT query on number of years

    First make a plan about how you're going to calculate the number of years; just subtracting two days won't give you years.

    Then consider creating a view with a computed column for the number of years - when you have it, filtering by the column will be trivial.

  • Mea_ Profile Picture
    60,284 on at
    RE: Filter AOT query on number of years

    Hi Daniyal Kashif,

    If qbr.value(strFmt('(%1 - %2) <= %3',

                   fieldStr(HcmPersonProfessionalExperience, EndDate)  ,

                   fieldStr(HcmPersonProfessionalExperience,StartDate), 5));

    return records that have experience greater than 5 days maybe it makes sense to multiple 5 *365 to get experience greater than 5 years ?

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
Martin Tocauer Profile Picture

Martin Tocauer 4

#1
Community Member Profile Picture

Community Member 4

#3
Nayyar Siddiqi Profile Picture

Nayyar Siddiqi 2

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans