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)

Using mthOfYr and year functions in where clause

(0) ShareShare
ReportReport
Posted on by

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

I have the same question (0)
  • Verified answer
    Martin Dráb Profile Picture
    237,697 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.

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

    ok, thank you

  • Martin Dráb Profile Picture
    237,697 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
    on at
    RE: Using mthOfYr and year functions in where clause

    Yes I got it. Thank you

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…

Neeraj Kumar – Community Spotlight

We are honored to recognize Neeraj Kumar as our Community Spotlight honoree for…

Leaderboard > 🔒一 Microsoft Dynamics AX (Archived)

#1
Priya_K Profile Picture

Priya_K 4

#2
Alexey Lekanov Profile Picture

Alexey Lekanov 3

#3
Scott_itD Profile Picture

Scott_itD 2 Community Manager

Last 30 days Overall leaderboard

Featured topics

Product updates

Dynamics 365 release plans