Aggregate version: 2.0.5
Collect version: 1.28.1
Is there any way how to construct a DateTime object (variable) within a form from given string or number? There is the date() function allowing to convert integer representing a number of days since 1.1.1970 to a DateTime object (https://docs.getodk.org/form-operators-functions/#converting-dates-and-time) but I did not find corresponding function for constructing a DateTime object including a time component.
I need to pre-set a value of a dateTime question based on previous calculations, namely retrieved from a QR code. Cold You advice me a correct way?
I'm getting the following error in the mobile application when I try the XML definition below (even when trying to convert just the date part):
Error evaluating field 'start-corrected' (/data/start-corrected[1]): The problem was located in Calculate expression for /data/start-corrected XPath evaluation: type mismatch The value "18169" can't be converted to date
I tried the following construction of the XML definition:
<data id="_pouziti_auta_oprava" version="{{form_version}}">
<start/>
<end/>
<username/>
<username-corrected/>
<predvyplnena_oprava/>
<predvyplnena_oprava_platna/>
<predvyplnena_oprava_typ/>
<predvyplnena_oprava_tmp/>
<predvyplnena_oprava_cas/>
<start-corrected/>
</data>
<bind nodeset="/data/predvyplnena_oprava" required="false()" type="barcode" />
<bind calculate="regex(/data/predvyplnena_oprava, '\w*?\|\w*?\|.*')" nodeset="/data/predvyplnena_oprava_platna" required="false()" type="boolean" />
<bind calculate="substring-before(/data/predvyplnena_oprava, '|')" nodeset="/data/predvyplnena_oprava_typ" required="false()" type="string" />
<bind calculate="substring-after(/data/predvyplnena_oprava, '|')" nodeset="/data/predvyplnena_oprava_tmp" relevant="/data/predvyplnena_oprava_platna" required="false()" type="string" />
<bind calculate="substring-before(/data/predvyplnena_oprava_tmp, '|')" nodeset="/data/predvyplnena_oprava_auto" relevant="/data/predvyplnena_oprava_platna" required="false()" type="string" />
<bind calculate="substring-after(/data/predvyplnena_oprava_tmp, '|')" nodeset="/data/predvyplnena_oprava_cas" relevant="/data/predvyplnena_oprava_platna" required="false()" type="string" />
<bind nodeset="/data/start-corrected" required="true()" type="dateTime" calculate="once(date(/data/predvyplnena_oprava_cas))"/>
Thanks Jan