Forum Discussion
Query Folding incorrect for Date.IsInPreviousNWeeks
- 2 years ago
Hi mike9999
I think this is correct.
The WHERE clause
where [_].[Source.Date] >= convert(date, '2023-04-09') and [_].[Source.Date] < convert(date, '2024-04-07')is equivalent to
where [_].[Source.Date] >= convert(date, '2023-04-09') and [_].[Source.Date] <= convert(date, '2024-04-06')since [Source.Date] is of type date.
Since 2023-04-09 is a Sunday and 2024-04-06 is a Saturday, this is a range of complete Sun-Sat weeks by the looks of it.
Does that look right or were you expecting something different?
Regards
Hi mike9999
I think this is correct.
The WHERE clause
where [_].[Source.Date] >= convert(date, '2023-04-09') and [_].[Source.Date] < convert(date, '2024-04-07')
is equivalent to
where [_].[Source.Date] >= convert(date, '2023-04-09') and [_].[Source.Date] <= convert(date, '2024-04-06')
since [Source.Date] is of type date.
Since 2023-04-09 is a Sunday and 2024-04-06 is a Saturday, this is a range of complete Sun-Sat weeks by the looks of it.
Does that look right or were you expecting something different?
Regards
- mike99992 years agoAdvocate I
Ah I understand now. I see on the Microsoft docs "Note that this function will return false when passed a value that occurs within the current week."
Intuitively- I would have assumed that Date.IsInPreviousNWeeks would return true for the current week- but really they mean the previous N FULL weeks excluding the week to date. I can solve my problem using another module!
Appreciate the quick response.
Mike