Select to view content in your preferred language

Arcade Date expressions

2751
6
Jump to solution
10-25-2023 03:08 AM
LouiseHarris1
Regular Contributor

Hi

I am configuring a form in Field Maps and want to auto calculate the date so have chosen to use Now(), however this also adds a time. What do I need to add to this function so it only auto fills with a date not a time too?

Tags (2)
0 Kudos
1 Solution

Accepted Solutions
JustinReynolds
Frequent Contributor

While you wait for the DateOnly() function with to become available you can use the following:

Set the field's input type to "date" rather than the default "date and time".  The user will then only see the date.

JustinReynolds_0-1698245789607.png

You can also use Today() instead of Now().  Today returns the current date at midnight, which is what will be stored in the database, but since you set the input type "Date" the user will of course only see the date.

 

- Justin Reynolds, PE

View solution in original post

6 Replies
DanPatterson
MVP Esteemed Contributor

DateOnly looks promising

Date functions | ArcGIS Arcade | ArcGIS Developers


... sort of retired...
LouiseHarris1
Regular Contributor

Yeah I tried that - DateOnly() but it doesn't work. I get the following message:

Test execution error: Compilation error - Line : 1, 0: Function not found. Verify test data

0 Kudos
KenBuja
MVP Esteemed Contributor

Are you using Enterprise? This new capability was just released in v1.24 and is only available in ArcGIS Pro 3.2, ArcGIS Online, and ArcGIS Maps SDK for Javascript 4.28. If you're on AGOL, this should be available after tonight's upgrade.

0 Kudos
DougBrowning
MVP Esteemed Contributor

All dates must have a time in Esri databases.  New fields for date only are coming very soon (maybe last night?).

If you want to just not show the time you can try setting the popup in the map and it may use that in the form.  It will still store a time.  123 does noon not sure on Field Maps.  It often uses midnight which causes issues later with time zone conversions.  So I just leave the time now.

0 Kudos
JustinReynolds
Frequent Contributor

While you wait for the DateOnly() function with to become available you can use the following:

Set the field's input type to "date" rather than the default "date and time".  The user will then only see the date.

JustinReynolds_0-1698245789607.png

You can also use Today() instead of Now().  Today returns the current date at midnight, which is what will be stored in the database, but since you set the input type "Date" the user will of course only see the date.

 

- Justin Reynolds, PE
DougBrowning
MVP Esteemed Contributor

I think this may default the time to midnight though.  Then it may show the day before when using the value in a web map that is in a different timezone.  Happens to me, esp with Alaska, and our users call about it.

0 Kudos