Forum Discussion
royalswe
5 years agoHelper I
Dynamic date in Odata query
I am fetching data from Dynamics 365 with OData and I only want to fetch data that is 3 days old or newer. I have this query and it works but the date is hardcoded as you can see. = ...
- 5 years ago
royalswe ,
Something like:
Date.ToText(Date.AddDays(Date.From(DateTime.FixedLocalNow()), -3), "yyyy-MM-dd")
Check if this functions helps:
Anonymous
5 years agoNot applicable
royalswe did this work for you in the service as well? I keep getting the error saying dynamic content can't be scheduled?
Thanks,
royalswe
5 years agoHelper I
No It didn“t work when scheduled in services.
I had to make the date filter in another row in the M query.
Like this
let
Source = OData.Feed("https://sandbox.operations.dynamics.com/Data/SupplyForecastEntries?"
&"$select=StartDate, SupplyTypeId, LastDate"
// &"&$filter=ForecastStartDate ge " & Date.ToText(Date.AddDays(Date.From(DateTime.FixedLocalNow()), -3), "yyyy-MM-dd")
, null, [Implementation="2.0"])
, #"Filtered Rows" = Table.SelectRows(Source, each [StartDate] >= [LastDate])
in
#"Filtered Rows"