Select to view content in your preferred language

arcade filter SQL DateAdd

361
3
01-22-2025 06:19 AM
Labels (2)
BartWolf
Emerging Contributor

Hi All,

Working on a dashboard serial chart (Enterprise 11.3)...
I'm trying to filter a featureset in a data-expression by evaluating 2 date-fields 

Here's my code...

var fs = FeatureSetByPortalItem(portal, '48ae0546f8ef4cd0b7039cd44ed0f4b4')
Console(Count(fs))
//var crFilt = `Date_Created < DateAdd(DATUM, -1, 'months')`  //not working
var crFilt = `Date_Created < DATEADD('month', -1, DATUM)`     //not working SQL92 syntax
var resFs =  Filter(resFs, crFilt);
Console(Count(resFs))

So I want to substract 1 month from the date in field [DATUM] and filter the records where [Date_Created] < recalculated fieldvalues...

Could this be done?  Or is "DateAdd" just not supported?
I'm getting this error in both cases: "Test execution error: Invalid parameters for call to DATEADD. Verify test data."

Thanks in advance..

 

0 Kudos
3 Replies
JoshuaBixby
MVP Esteemed Contributor

Manipulating dates and times are very data source specific, so it would be helpful if you shared the back-end data store the data resides in.

0 Kudos
BartWolf
Emerging Contributor

It's a hosted feature layer, So I'm using the ArcGIS relational datastore on ArcGIS 11.3.

0 Kudos
JoshuaBixby
MVP Esteemed Contributor

The ArcGIS Relational Data Store is based on PostgreSQL, which doesn't support DATEADD.  Try using native PostgreSQL Date/Time functions:  https://www.postgresql.org/docs/current/functions-datetime.html