Skip to main content

Notifications

Microsoft Dynamics AX (Archived)

Using mthOfYr and year functions in where clause

Posted on by 11,873

I try to use mthOfYr and year functions in a where clause as explained below. When I compile the query the following error message is received (Illegal use of WHERE expression). How can I use these functions in a where clause?

 

select sum (Value) from SalaryCalcDetails where mthOfYr(SalaryCalcDetails.CalcDate)==1

                                               && year(SalaryCalcDetails.CalcDate)==2012;

*This post is locked for comments

  • maram fraij Profile Picture
    maram fraij 11,873 on at
    RE: Using mthOfYr and year functions in where clause

    Yes I got it. Thank you

  • Martin Dráb Profile Picture
    Martin Dráb 229,928 Most Valuable Professional on at
    RE: Using mthOfYr and year functions in where clause

    Please verify the answer if you got what you needed.

  • maram fraij Profile Picture
    maram fraij 11,873 on at
    RE: Using mthOfYr and year functions in where clause

    ok, thank you

  • Verified answer
    Martin Dráb Profile Picture
    Martin Dráb 229,928 Most Valuable Professional on at
    RE: Using mthOfYr and year functions in where clause

    You can't use X++ functions in SQL queries. Find first and last day of the month and use normal relation operators (>, <, =).

     Or you could create a view with a computed column and there you can use T-SQL functions.

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!

Community AMA December 12th

Join us as we continue to demystify the Dynamics 365 Contact Center

New! Quick response templatesâš¡

Save time with the new custom templates!

Leaderboard

#1
André Arnaud de Calavon Profile Picture

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

#2
Martin Dráb Profile Picture

Martin Dráb 229,928 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans