# Fix a date and time from and to in the relevant field

**URL:** <https://forum.getodk.org/t/fix-a-date-and-time-from-and-to-in-the-relevant-field/17155>\
**Category:** Support\
**Tags:** odk-xlsform\
**Created:** [January 11, 2019, 12:39am UTC](https://forum.getodk.org/t/fix-a-date-and-time-from-and-to-in-the-relevant-field/17155 "2019-01-11T00:39:51Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![Manne\_Munikumar](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/manne_munikumar/32/7984_2.png) [@Manne\_Munikumar](https://forum.getodk.org/u/Manne_Munikumar)\
**Post date:** [January 11, 2019, 12:39am UTC](https://forum.getodk.org/t/fix-a-date-and-time-from-and-to-in-the-relevant-field/17155/1 "2019-01-11T00:39:51Z")

</div>

Hi,  
How to fix a date in the relevant field like I want to select the children who born from zero days to 42 days from the date of birth and 46days to 98 days respectively. I tried (int(today() - ${dob})) \>= '0' and (int(today() - ${dob})) \<= '42'  
and  
(int(today() - ${dob})) \>= '0' or (int(today() - ${dob})) \<= '42'  
i am not getting what i epected.

---

<div class="post-metadata">

**Author:** ![Xiphware](https://getodk.b-cdn.net/user_avatar/forum.getodk.org/xiphware/32/2587_2.png) [@Xiphware](https://forum.getodk.org/u/Xiphware)\
**Post date:** [January 11, 2019, 1:31am UTC](https://forum.getodk.org/t/fix-a-date-and-time-from-and-to-in-the-relevant-field/17155/2 "2019-01-11T01:31:41Z")

</div>

Dates and DateTimes are represented as _strings_ in ODK, eg "2019-01-11". So you can compare two dates to see if they are the same by using '=' or '!=' which just checks that's the two strings are identical. Similarly, because of the unique format of these strings - "YYYY-MM-DD" - you can also check the relative order of two dates using '\<' or '\<=', but only because it compares each string character-by-character, and the character '0' happens to be less than the character '1'... But to perform any other numerical operation on Dates and DateTImes, such as _subtracting_ two Dates to find the number of days/months/years between them, is an operation that cannot be performed _on strings_. Instead, you must first convert these dates to an actual _numeric_ representation, using the [decimal-date-time(dateTime)](http://decimal-date-time(dateTime)) function. eg to find the number of days between two dates:

`decimal-date-time(${date1}) - decimal-date-time(${date2})`

Hopefully that explains why yer not getting what you expect... 😉 Try using decimal-date-time() instead.
