Forum Discussion
Formatting Date in query editor
Hi All,
I am using query editor to call web.content through an API.
In the api i Pass the date something like StartDate >= 2022-02-01 AND EndDate<= 2022-02-28. I need this to be moving window of 30 days hence i want this to be calculated.
I already get the number of pages API is returning and store in table before i pass recursively to the final API. There i want to add columns of start date and end date.
The problem I am facing is when add column with Date.From(DateTime.LocalNow() i get the date as 3/1/2022 which is mm/dd/yyyy and seprated by slashes.
But for passing it to the query the date format should be yyyy-mm-dd seprated by the dashes i.e. 3/1/2022 -> 2022-03-01
Please help with the issue
Thanks
Anuj
Anonymous , You can use Date.ToText on Date.From(DateTime.LocalNow())
https://docs.microsoft.com/en-us/powerquery-m/date-totext
4 Replies
- amitchandakSuper User
Anonymous , You can use Date.ToText on Date.From(DateTime.LocalNow())
https://docs.microsoft.com/en-us/powerquery-m/date-totext
- AnonymousNot applicable
OK it worked with some parameters thanks fo the insights.
Just for the help of community here is what i did Date.ToText(Date.From(DateTime.LocalNow()),"s")
- AnonymousNot applicable
Hi amitchandak Date.From(DateTime.LocalNow()) retruns text so the Date.ToText conversion does not work Am I missing something here
- AnonymousNot applicable
My apologies it works but Date.ToText(Date.From(DateTime.LocalNow()), [Format = "yyyy-mm-dd"]), the format i need is not getting created