When implementing temporal datetime pairs, which is the better approach?
Approach 1
_RK FROM_DTTM TO_DTTM
1 01-JAN-2012 00:00:00 31-DEC-2012 23:59:59 ------------> Old record closed out
1 01-JAN-2013 00:00:00 31-DEC-4949 23:59:59 ------------> New active record
Used with a filter clause as follows:
where FROM_DTTM <= &FILTER_DATE <= TO_DTTM
Approach 2
_RK FROM_DTTM TO_DTTM
1 01-JAN-2012 00:00:00 01-JAN-2013 00:00:00 ------------> Old record closed out
1 01-JAN-2013 00:00:00 31-DEC-4949 23:59:59 ------------> New active record
Used with a filter clause as follows:
where FROM_DTTM <= &FILTER_DATE < TO_DTTM
Considerations:
Approach 1 is compatible with BETWEEN clause syntax (inclusive range). For this reason I think that it is the best approach, however - and this is my concern - there will always exist a gap between the closing and opening timestamps! Eg the following will (incorrectly from a business perspective) return nothing:
where FROM_DTTM <= '31-DEC-2012 23:59:59.1'dt <= TO_DTTM
Different databases will have differing levels of precision here. I guess there would have to be standard (always round to the nearest second when filtering) but just wondered if there were any other reasons to support Approach 1 (such as proposed bi-temporal 'AS OF' syntax compatibility)? Or indeed, whether (and why) Approach 2 would be preferable..