Arcade date expression issue not working with QuickCapture

254
4
Jump to solution
3 weeks ago
ScumBagSurfer
New Contributor II

I have created a quick capture project and field map project using the same hosted feature layer. Within this layer, I have a date field which uses a calculated expression of:

Now()

which gets the current date and time of user input.

I then have a string field which formats this date to how I want.

An example of this would be 

dd/mm/yyyy, hh:mm AM/PM

12/04/2024, 10:45 AM

This arcade expression is:

//  Input Date

// AM or PM for minutes
var ampm = When(Hour(Now()) < 12, "AM", "PM");

// Getting current minutes/s
var minutes = Minute(Now());
// Adding 0 when the minute is a single digit
var paddedMinutes = When(minutes < 10, "0" + minutes, Text(minutes));

// Getting a current hour
var hours = Hour(Now());
// Adding 0 when the hour is a single digit
var paddedhours = when(hours<10,"0"+hours, Text(hours));

// Getting current day
var days = Day(Now());
// Adding 0 when the day is single digit
var paddeddays = when(days<10,"0"+days, Text(days));

// Adding 1 to adjust for zero-indexed months
var months = Month(Now()) + 1;
// Adding 0 when the month is single digit
var paddedmonths = when(months<10, "0"+months, Text(months));

// Final code
paddeddays +
  "/" +
  paddedmonths +
  "/" +
  ISOYear(Now()) +
  ", " +
  paddedhours +
  ":" +
  paddedMinutes +
  " " +
  ampm;
 
This is the result when I see the data in ArcGIS Online (see attached).
 
The dates where it is working are all points collected in field maps while the ones where it hasn't are all in QuickCapture.
 
 
0 Kudos
1 Solution

Accepted Solutions
KenBuja
MVP Esteemed Contributor

This doesn't address the QuickCapture question, but you can get that formatting much easier using the Text function

Text(Now(), "DD/MM/YYYY, hh:mm A"); 

The only thing is doesn't address is the ISOYear, but I'm not clear on why you would want that. If you used your formula on a date like 31 December 2024, it would return "31/12/2025"

View solution in original post

0 Kudos
4 Replies
KenBuja
MVP Esteemed Contributor

This doesn't address the QuickCapture question, but you can get that formatting much easier using the Text function

Text(Now(), "DD/MM/YYYY, hh:mm A"); 

The only thing is doesn't address is the ISOYear, but I'm not clear on why you would want that. If you used your formula on a date like 31 December 2024, it would return "31/12/2025"

0 Kudos
KenBuja
MVP Esteemed Contributor

Which version of QuickCapture are you using? Arcade wasn't supported in versions before 1.18.

0 Kudos
ScumBagSurfer
New Contributor II

Thanks, I have tested this expression out and it seems to be working when I captured some test points.

0 Kudos
JohnathanHasthorpe
Esri Regular Contributor

I have found that the original expression is failing in QuickCapture because of the comma followed by a space ", " . It looks like this is an ArcGIS Runtime bug. If you remove the comma the above will work.

But the following will work: Text(Now(), "DD/MM/YYYY, hh:mm A"); 

0 Kudos