Hello all, a brief explanation, so i have an old VB Script that i need to convert into use within ArcGIS Pro.
the script should do the following, if there is a date in the "SurveyDay" field it should add on the number of months in the "Reinspection_Period" field and set a new date into the future within "SurveyDay" field based on the VB Script.
Regular inspected trees | 12/06/2019 12:05:19 | 36 | DateAdd ( "m", "Reinspection_Period" , "SurveyDay" ) |
so if the date was 12th June 2019 and we wanted to add 36 months onto this date it would set the date as 12th June 2022 HH:MM:SS the same if the number in this field was either a 6, 12 or any number typed in this "Reinspection_Period" Field
However i cannot get any script to work and anything i try generates <Null> values within the "SurveyDay" Field.
Can anyone help with the conversion from VB into either Arcade or Python expression when using the field calculate on the required column?
Thank you
Solved! Go to Solution.
The DateAdd function expects the input date first, then the value to be added, then the units. The units have to be spelled out ("months" instead of "m"). This code checks if there is a date in the SurveyDay field, then adds the proper number of months.
if (!IsEmpty($feature.SurveyDay)) DateAdd($feature.SurveyDay, $feature.Reinspection_Period, 'months')
The DateAdd function expects the input date first, then the value to be added, then the units. The units have to be spelled out ("months" instead of "m"). This code checks if there is a date in the SurveyDay field, then adds the proper number of months.
if (!IsEmpty($feature.SurveyDay)) DateAdd($feature.SurveyDay, $feature.Reinspection_Period, 'months')
Thanks for the Help Ken!. i have tried this script out and it functions as intended.
any undefined values within the Re-Inspection Period (Months) will generate the same date in the column Re_inspection Date which is absolutely fine and expected if there is no number it cannot add on the required number of Months.
Super Appreciated for your help on this