Forum Discussion
Filtering on DateTime.LocalNow()
- Anonymous1 year ago
Hi Anonymous,
Thanks for reaching out to the Microsoft fabric community forum.
Based on what you've described and the SQL captured in Profiler, it looks like DateTime.LocalNow() is being evaluated on the client side (within Power BI), and its value is getting embedded as a static literal in the folded SQL query. That’s why the timestamp doesn’t change across refreshes, and the warehouse ends up returning cached results.
Even though the query folds, not all M functions translate to equivalent SQL functions. In this case, DateTime.LocalNow() doesn’t get translated into something like GETDATE() at the SQL level, it gets evaluated at the time the query is generated, and the resulting timestamp is pushed to SQL as a fixed value.
If your goal is to force a fresh timestamp on every query execution (e.g., for stress testing), we’d recommend moving the date filtering logic into a SQL view or using a native SQL query with GETDATE() directly, this ensures the timestamp is evaluated inside the warehouse each time, and avoids hitting the cache.
I would also take a moment to thank lbendlin, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.
Community Support TeamIf this post helps then please mark it as a solution, so that other members find it more quickly.
Thank you.
Hi Anonymous,
Thanks for reaching out to the Microsoft fabric community forum.
Based on what you've described and the SQL captured in Profiler, it looks like DateTime.LocalNow() is being evaluated on the client side (within Power BI), and its value is getting embedded as a static literal in the folded SQL query. That’s why the timestamp doesn’t change across refreshes, and the warehouse ends up returning cached results.
Even though the query folds, not all M functions translate to equivalent SQL functions. In this case, DateTime.LocalNow() doesn’t get translated into something like GETDATE() at the SQL level, it gets evaluated at the time the query is generated, and the resulting timestamp is pushed to SQL as a fixed value.
If your goal is to force a fresh timestamp on every query execution (e.g., for stress testing), we’d recommend moving the date filtering logic into a SQL view or using a native SQL query with GETDATE() directly, this ensures the timestamp is evaluated inside the warehouse each time, and avoids hitting the cache.
I would also take a moment to thank lbendlin, for actively participating in the community forum and for the solutions you’ve been sharing in the community forum. Your contributions make a real difference.
If I misunderstand your needs or you still have problems on it, please feel free to let us know.
Best Regards,
Hammad.
Community Support Team
If this post helps then please mark it as a solution, so that other members find it more quickly.
Thank you.
- Anonymous1 year agoNot applicable
Hi Anonymous,
As we haven’t heard back from you, so just following up to our previous message. I'd like to confirm if you've successfully resolved this issue or if you need further help.
If yes, you are welcome to share your workaround and mark it as a solution so that other users can benefit as well. If you find a reply particularly helpful to you, you can also mark it as a solution.
If you still have any questions or need more support, please feel free to let us know. We are more than happy to continue to help you.
Thank you for your patience and look forward to hearing from you.- Anonymous1 year agoNot applicable
Hi Anonymous,
I wanted to check if you had the opportunity to review the information provided. Please feel free to contact us if you have any further questions. If my response has addressed your query, please accept it as a solution so that other community members can find it easily.
Thank you.- Anonymous1 year agoNot applicable
Hi Anonymous,
May I ask if you have resolved this issue? If so, please mark the helpful reply and accept it as the solution. This will be helpful for other community members who have similar problems to solve it faster.
Thank you.