Calculate text value from Date field value

1917
4
Jump to solution
11-18-2016 10:27 AM
JoeFlannery
Honored Contributor

I would like to automatically populate a "Season" text field in my bird survey given a DateTime value in the survey.  The “Bird Seasons” that I am using are shown below.  In my survey, I already have a DateTime field.  Can I use a formula or calculation to grab the DateTime value and pick the right Bird Season that corresponds to the date?  Any guidance is much appreciated.

 

Bird Seasons

Winter = Nov. 1 thru Feb. 29

Spring = March 1 thru May 31

Summer = June 1 thru July 31

Fall = Aug. 1 thru Oct. 31

 

 

Thank you,

Joe

0 Kudos
1 Solution

Accepted Solutions
JoeFlannery
Honored Contributor

Ismael:

Thank you for your insightful response worked for me!  I'm sure others will find it useful.

We are all new to Survey123 and, I'm guessing, most of us are new to XLSform coding, too. My major takeaway from your response is that Excel formulas can be used in the XLSform that drives Survey123. I am learning a lot by building my first Surveys and I appreciate your Survey123 GeoNet blog posts, Survey123 online help and your personal responses to GeoNet questions. Hats off to you and your great team!

Joe

View solution in original post

4 Replies
IsmaelChivite
Esri Notable Contributor
typenamelabelcalculation
dateaDateDate
calculatemMonthformat-date(${aDate},'%n')
calculatedayDayformat-date(${aDate},'%e')
textseasonSeasonif(${m}>10,'Winter',if(${m}>7,'Fall',if(${m}>5,'Summer',if(${m}>2,'Spring','Winter'))))
NathanEnge
Esri Contributor

Ismael

I am trying to format my date field as: 

format-date(${DATES},'%Y/%n/%e')

but what shows up on the survey is %Y/%n/%e

 

Any clues on how to best format the date as text to show yyyy/mm/dd or better yet yyyy_mm_dd?

0 Kudos
JoeFlannery
Honored Contributor

Ismael:

Thank you for your insightful response worked for me!  I'm sure others will find it useful.

We are all new to Survey123 and, I'm guessing, most of us are new to XLSform coding, too. My major takeaway from your response is that Excel formulas can be used in the XLSform that drives Survey123. I am learning a lot by building my first Surveys and I appreciate your Survey123 GeoNet blog posts, Survey123 online help and your personal responses to GeoNet questions. Hats off to you and your great team!

Joe

AbdulabnanMohammed
Occasional Contributor

Hi @IsmaelChivite & Experts

I would like to include in between the date from and to and I have Applied a logic by going through your idea but it fails when i choose 27th feb 2026 then spring should be populated but it is considering winter
I have attached the XLS, Need  Guidance how to correct or what i missed

I shall be thankful 

WinterWinterFrom 11 Nov to 19 Feb.
SpringSpringFrom 20 Feb. to 20 May
SummerSummerFrom 21 May to 14 Aug
AutumnAutumnFrom 15 Aug. to 10 Nov
0 Kudos