Select to view content in your preferred language

get day number in week

658
1
Jump to solution
06-22-2023 08:29 AM
mikaël
Frequent Contributor

I'm trying to get the number of the current day in the week where Monday would be 0 or 1 and Sunday would be 6 ou 7 or something like that.

Arcade and Field Maps have isoweekday() but I can't seem to do it with survey123.

I realize I can get the first three letters of the day name (format-date(today(),'%a')), but it would really be easier with the day number.

Thanks!

0 Kudos
1 Solution

Accepted Solutions
ZacharySutherby
Esri Regular Contributor

Hello @mikaël

You can use a JavaScript function to perform the calculation. The JavaScript Date object has a getDay method that returns the day of the week between 0 and 6. You can add 1 to the number returned to return 1-7. I've attached a sample survey that demonstrates the workflow. 

Thank you,
Zach

View solution in original post

1 Reply
ZacharySutherby
Esri Regular Contributor

Hello @mikaël

You can use a JavaScript function to perform the calculation. The JavaScript Date object has a getDay method that returns the day of the week between 0 and 6. You can add 1 to the number returned to return 1-7. I've attached a sample survey that demonstrates the workflow. 

Thank you,
Zach