Skip to main content

Notifications

Announcements

No record found.

Microsoft Dynamics AX (Archived)

Using mthOfYr and year functions in where clause

(0) ShareShare
ReportReport
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 230,445 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 230,445 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!

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,391 Super User 2024 Season 2

#2
Martin Dráb Profile Picture

Martin Dráb 230,445 Most Valuable Professional

#3
nmaenpaa Profile Picture

nmaenpaa 101,156

Leaderboard

Featured topics

Product updates

Dynamics 365 release plans