I have a strange issue related to set a complex definition expression with date field queries to mapservice subLayer the issue was introduced with me in arcgis sdk with ios and with kotlin as well
and then I have made sure this is not related to the sdk itself so I have tried with arcgis js api and I found out this:
- for setting the expression that includes date time queries to feature layer it works well as expected
-for setting the expression that includes date time queries to map service sublayer it doesn't work as expected at all and it returns all features in layer
var dynamicMapServiceLayer = new FeatureLayer({
url: "https://myhost/server/rest/services/App/app/MapServer/1",
id: 'baseMap',
definitionExpression: "USER_NAME = 'test' AND (SIGHTING_DATE >= DATE '2025-02-17' AND SIGHTING_DATE < DATE '2025-02-18')"
});
var dynamicMapServiceLayer = new MapImageLayer({
url: "https://myhost/server/rest/services/App/app/MapServer",
id: 'baseMap',
sublayers: [
{
id: 1,
visible: true,
definitionExpression: "USER_NAME = 'test' AND (SIGHTING_DATE >= DATE '2025-02-17' AND SIGHTING_DATE < DATE '2025-02-18')"
}
]
});
I guess it is an issue with server of how to process definition expression for both
I hope to resolve this issue soon
Solved! Go to Solution.
I found a solution for this. The reason why this issue is our used database is SQL Server so the syntax for definition expression [for date time] is not proper for SQL Server in export map service request so when I use this:
"USER_NAME = 'test' AND SIGHTING_DATE BETWEEN CAST('2025-02-17' AS DATE ) AND CAST('2025-02-18' AS DATE))"
I found a solution for this. The reason why this issue is our used database is SQL Server so the syntax for definition expression [for date time] is not proper for SQL Server in export map service request so when I use this:
"USER_NAME = 'test' AND SIGHTING_DATE BETWEEN CAST('2025-02-17' AS DATE ) AND CAST('2025-02-18' AS DATE))"