Select to view content in your preferred language

Is there secret tricks to work with dates in Dashboards and Arcade?

1006
1
09-01-2023 03:03 PM
EduardoDiaz
Emerging Contributor

Hi everyone, I've been working with dashboards and I'm aware of some situations related with work with date fields.

I have a service that is setted as GMT-6 America Central since I published it from ArcGIS Pro, I can compare the service with the data in our Enterprise GDB and everything matchs. I've applied date selectors in some dashboards that works as I expected, nevertheless now I'm trying to generate a dynamic date period dictionary using arcade within a data expression in ArcGIS Dashboards.

The code is:

 

var portal = Portal('https://.../portal/');
var fs = FeatureSetByPortalItem(
    portal,
    '5199a3d3959a402ebf5ac0dec80baf50',
    0,
    [   'OBJECTID',
        'FECHA_Y_HORA_INICIO_LLAMADA', //date field
        'TIPO', 'SUBTIPO', 'INCIDENTE'],
    false
);

var dia_actual = Day(Now()) //getting current day
var mes_actual = Month(Now()) //getting current month
var ano_actual = Year(Now()) //getting current year
var ano_pasado = ano_actual-1 //subtracting one from year

//creating two dates to get the same time period but from the last year
var f_min = Date(ano_pasado, mes_actual, '01', '00', '00','00')
var f_max = Date(ano_pasado, mes_actual, dia_actual, '23', '59', '59')

console(f_min)
console(f_max)

//filtering my service using the created dates
var dic_ano_pasado = Filter(fs, 'FECHA_Y_HORA_INICIO_LLAMADA >= @f_min AND FECHA_Y_HORA_INICIO_LLAMADA <= @f_max')

//it works!
return dic_ano_pasado

 

Although my code works I don't get the expected result since the dates that I generated are setted as GMT-5 and this affects the period that I looking for, getting "x" rows for the requested period and "y" for the 1 hour difference.

 

Console messages:

//2022-09-01T00:00:00-05:00
//2022-09-01T23:59:59-05:00

 

CharChar

 

As I mentionated the expected result is data only for September 1. (Is september 1 when I'm publishing this post.)

Researching I found that Arcade works with the local time zone but my time zone is GMT-6 just like my service, knowing this, Is there a way to asign the time zone as parameter of the Date function? and why the arcade time zone is different?

Moreover, I want to ask, the difference between arcade time zone and my time zone is an issue with our portal instalation?

0 Kudos
1 Reply
CCGIS
by
Occasional Contributor

Hi @EduardoDiaz not sure if this will help you. In the past what I have done is publish the layer in UTC. And see if that works. 

0 Kudos