Skip to content
This repository has been archived by the owner on Jun 16, 2024. It is now read-only.

ConditionOperator.LastMonth should ignore time of date #551

Open
bwmodular opened this issue Mar 30, 2021 · 4 comments
Open

ConditionOperator.LastMonth should ignore time of date #551

bwmodular opened this issue Mar 30, 2021 · 4 comments

Comments

@bwmodular
Copy link
Contributor

Describe the bug
The ConditionOperator.LastMonth condition operator brings back different results depending on the time component of the date being queried.

To Reproduce
Today is the 31st March 2021.

If I create a record with a date column with this value:
28/02/2021 00:00:00
then the condition operator ConditionOperator.LastMonth retreives the record.

If I create a record with a date column with this value:
28/02/2021 12:06:18
then the condition operator does not return the record.

Expected behavior
Both of these dates should be found by the query, as they are both in the last month: February.
Both of these dates are found when querying a real v9 instance of CRM.

** FakeXrmEasy and Dynamics 365 / CRM version **
v9

Screenshots
Here's a screenshot of a query where the date is set to an exact date, no time component - 28/02/2021 00:00:00
You can see that the query returns one row:
image

Here's a screenshot of a query where the date is set to date with a time - 28/02/2021 12:11:25
You can see that no rows are returned:
image

Both of these queries should return one row when using the 'last month' criteria.

@bwmodular bwmodular added the bug label Mar 30, 2021
@jordimontana82
Copy link
Owner

Thanks for raising this Ben. Much appreciated.

@jordimontana82 jordimontana82 added this to the v2.x milestone Mar 30, 2021
@bwmodular
Copy link
Contributor Author

I can't quite work out why this is happening. These tests have been working for weeks, and suddenly stopped working. I think it must either be because we're near a month boundary and the number of days in the previous month is less than the number of days in this month, or because we (in the uk) have just switched to daylight saving, or something like that. Date related tests are always tricky - they have a habit of working on some days and not others! I'll try to remember to test it every day and see if they start working again on 1st of April...

@jordimontana82
Copy link
Owner

That could well be Ben, if you try inititalising the date fields as Utc, does it make any difference?

@bwmodular
Copy link
Contributor Author

The tests are succeeding again this morning, no doubt because it is the first of a new month (1st April).
I will reinstate the tests in my build pipeline and see if/when they fail in the future, although we may not see this for a while because we don't commit to this pipeline every day.
I may have to just rewrite the tests by making sure the date I create is on (say) the 1st of the previous month, rather than using Today.addmonths(-1). That would stop the build failing but it wouldn't fix the problem with FakeXrmEasy.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

2 participants