(monthrange()) query isn't changing

I am using AX2012R3 and have created a query which I am using in a view. It is looking at sales invoices and I have created a range on invoice date using the (monthrange()) function which I hoped to display the current month data only.

It appeared to be working fine but when April came the query seemed to be stuck in March and it wasn’t until I went into the AOT and re-saved the query did it reflect the current months data.

I have been able manipulate the data displayed using the AX session date but each time a re-save of the query is needed to reflect the changes.

Has anyone had any experience of this before?

Thanks

monthRange() is a method defined in AX, while views are objects defined in T-SQL in SQL Server. You can’t refer to X++ from SQL.

I expect that the method is evaluated when synchronizing AX application with database and what you’ll find in SQL server is the value returned by the method. It obviously won’t change by itself.

You can verify it by looking directly to SQL Server. I will appreciate if you do it and let us know, especially if it doesn’t look exactly as I described. It may be useful to know.