I need to create simple query which will show all contracts which will expire in next 3 months. I know how to do that with SQL, but how to do that in Visual Studio when I create query. I added data source Contract table. Added range. Column where is date about expiring is VALIDTO. So, something to write up in value, or how to do that ?
Asked
Active
Viewed 666 times
0

rjv
- 1,058
- 11
- 29

DarthCSharper
- 133
- 1
- 13
-
1Take a look at [Class QueryBuildRange](https://learn.microsoft.com/en-us/dynamics365/unified-operations/dev-itpro/dev-ref/q-classes#class-querybuildrange) and [Advanced date queries that use SysQueryRangeUtil methods](https://learn.microsoft.com/en-us/dynamics365/unified-operations/fin-and-ops/get-started/advanced-filtering-query-options#advanced-date-queries-that-use-sysqueryrangeutil-methods). – FH-Inway Jul 02 '19 at 15:48
-
When you say `query`, how do you plan to use it? Do you want to access it from SQL, listpage/grid, etc? Or are you wanting to use `x++` code with business logic? If you can easily do it from SQL, you may consider creating a `View`. You can use AX's `select` syntax or create a query object, etc. The answer to your question depends on the other factors. – Alex Kwitny Jul 02 '19 at 20:33
-
@AlexKwitny I need it because I want to make Tile on Workspace which will show me number of contracts which expiring in next 3 months. So, it will be some kind of moving window. Until now, every time when I made Tile, I used the simple queries. – DarthCSharper Jul 03 '19 at 08:34
-
Possible duplicate of [D365 FO - Passing date range in query](https://stackoverflow.com/questions/56889905/d365-fo-passing-date-range-in-query) – FH-Inway Jul 05 '19 at 13:32
1 Answers
-1
Solved with two ranges on VALIDTO column. Used (MonthRange(0,3)) with (Day(0)) formulas.

DarthCSharper
- 133
- 1
- 13