SDV icon indicating copy to clipboard operation
SDV copied to clipboard

Constraints should ignore the time when comparing a datetime vs. date

Open npatki opened this issue 4 years ago • 0 comments

Problem Description

I have a dataset that has two columns bound by a GreaterThan constraint. The first column contains a datetime while the second column contains a date only.

Column A Column B
2014-08-11 07:46:58 2014-09-27
2014-08-09 18:08:18 2014-08-09
2014-08-23 10:11:34 2014-09-01

The general constraint I have is: Column A <= Column B, which is true if you ignore the time part of Column A. However, when I add this as a GreaterThan constraint, I get a ConstraintsNotMetError error.

Expected behavior

I expect a GreaterThan constraint to work on this data.

Internally, I suspect that whenever there is only a date object (without a time) we're implicitly adding a 00:00:00 as the time. Therefore, certain comparisons with GreaterThan don't pass the test.

If there is a comparison being made with a date vs. datetime, we should ignore the time part because it isn't actually comparable.

npatki avatar Dec 06 '21 22:12 npatki