Hello,
I'm trying to pass field values to different columns, and also remove the time in the date (like in the image below). I wrote a piece of code but it doesn't work.

// Reference layer using the FeatureSetByPortalItem() method.
var fs = FeatureSetByPortalItem(Portal('https://arcgis.com/'), '74d6c3d630c14458a3c23c71a19447ad', 0, ['*'], false);
// Empty dictionary to capture each value
var choicesDict = {'fields': [{ 'name': 'ID', 'type': 'esriFieldTypeString'},
{ 'name': 'dates', 'type': 'esriFieldTypeDate'},
{ 'name': 'morning', 'type': 'esriFieldTypeString'},
{ 'name': 'afternoon', 'type': 'esriFieldTypeString'},
{ 'name': 'night', 'type': 'esriFieldTypeString'}],
'geometryType': '',
'features': []};
// Store values in the dictionary
for (var feature in fs) {
var id = feature['ID']
var actdate = feature['actionDate']
var morning = feature['Shift_vehicles'] == 'Morning check (6-7am)'
var afternoon = feature['Shift_vehicles'] == 'Afternoon check (2-4pm)'
var night = feature['Shift_vehicles'] == 'Night check (11pm-1am)'
Push(choicesDict.features, {"attributes": {"ID": id,
"dates": actdate,
"morning": morning,
"afternoon": afternoon,
"night": night}})
}
//return choicesDict
// Convert dictionary to featureSet.
var fs_dict = FeatureSet(Text(choicesDict));
return fs_dict
// Return featureset
return GroupBy(fs_dict, ['ID', 'dates'],
[{ name: 'morning', expression: 'morning', statistic: 'COUNT' },
{ name: 'afternoon', expression: 'afternoon', statistic: 'COUNT' },
{ name: 'night', expression: 'night', statistic: 'COUNT' }]);