Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now! Learn more

Reply
Anonymous
Not applicable

variable in API URL JSON

Hello people,

I am using a JSON API string to fetch date from a date range which is parameterized. Because of that I have to change values everyday to fetch details. This URL look something like this :

 

Source = Json.Document(Web.Contents(XXXXXX&from_date=2018-07-01+00%3A00%3A00&to_date=2018-07-18+12%3A00%3A00&XXXXX"))

 

Now I need to set to_date as TODAY() in yyyy-mm-dd hh:mm:ss format. Help me with this.

 

Thanks and Regards,

Piyush

3 REPLIES 3
v-jiascu-msft
Microsoft Employee
Microsoft Employee

Hi Piyush,

 

Please try the function datetime-localnow. It could be like below.

let
    now = DateTime.LocalNow(),
    Source = Json.Document(Web.Contents(XXXXXX&from_date=2018-07-01+00%3A00%3A00&to_date=now))
in
    Source

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.
Anonymous
Not applicable

Hi Dale,

Thanks for your help. I tried your way but it's not resolving my purpose instead it's showing following error :

 

Capture.PNG

 

I also tried this -> now = Date.AddDays(Date.From(DateTime.LocalNow()),-1),

Kindly suggest

 

Thanks,

Piyush

Hi Piyush,

 

It seems the error was raised by other errors. Can you share the file or the Power Query code?

 

Best Regards,

Dale

Community Support Team _ Dale
If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.

Helpful resources

Announcements
Power BI DataViz World Championships

Power BI Dataviz World Championships

The Power BI Data Visualization World Championships is back! Get ahead of the game and start preparing now!

December 2025 Power BI Update Carousel

Power BI Monthly Update - December 2025

Check out the December 2025 Power BI Holiday Recap!

FabCon Atlanta 2026 carousel

FabCon Atlanta 2026

Join us at FabCon Atlanta, March 16-20, for the ultimate Fabric, Power BI, AI and SQL community-led event. Save $200 with code FABCOMM.

Top Solution Authors