Forum Discussion

mike9999's avatar
mike9999
Advocate I
2 years ago
Solved

Query Folding incorrect for Date.IsInPreviousNWeeks

Hi- I think that that query folding is incorrect for Date.IsInPreviousNWeeks. Any suggestions on how to fix the m-code on my end, or can anyone confirm this is a bug and how to request this gets fix...
  • OwenAuger's avatar
    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