Stream: fhirpath
Topic: When to apply timezone when comparing datetimes?
Paul Lynch (Jul 12 2019 at 14:08):
Should this be true or false?
@2018-12-11T11:59-04:00 < @2018-12-11T11-4:30
(date and hour and the same, minutes and offset are different)
If you apply the rule about limiting the precision first, before the timezone, that becomes:
@2018-12-11T11-04:00 < @2018-12-11T11-4:30
which is true.
But, if you apply the timezone offset first you get:
@2018-12-11T15:59Z < @2018-12-11T15:30Z
which is false.
Paul Lynch (Jul 12 2019 at 14:08):
I think the offset should probably be applied first.
Paul Lynch (Jul 12 2019 at 14:09):
This has a bigger impact if you allow timezone offsets without times, as in:
@2018-11-01T-04:00 < @2018T-04:30
Paul Lynch (Jul 12 2019 at 17:38):
I guess this is really only a question for the STU1 fhirpath. The recently balloted version says it should return empty if the precisions are not the same.
Bryn Rhodes (Jul 15 2019 at 16:35):
For relative comparisons, empty would only be returned for differing precisions if that precision was reached in the comparison: http://hl7.org/fhirpath/2019May/#comparison
Bryn Rhodes (Jul 15 2019 at 16:36):
As far as whether to apply the offset first, normalize the offset prior to performing the comparison. Specifically, "To support comparison of DateTime values, either both values have no timezone offset specified, or both values are converted to a common timezone offset."
Last updated: Apr 12 2022 at 19:14 UTC