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

Calling all Data Engineers! Fabric Data Engineer (Exam DP-700) live sessions are back! Starting October 16th. Sign up.

Reply
DocDri
Helper I
Helper I

Hand over date from last year to URL

Hello,

 

what I want to do is to hand over the date from last year (-365 days) to a URL as text for my web source. As I'm pretty new to power query I tried this:

 

Source = Json.Document(Web.Contents("https://myurl.com/visits?startDate=" & Text.From(Date.Year(Date.AddDays(DateTime.LocalNow,-365))) & "-" & Text.From(Date.Month(Date.AddDays(DateTime.LocalNow,-365))) & "-" & Text.From(Date.Day(Date.AddDays(DateTime.LocalNow,-365)) & "&limit=500")))

 

But that does not work. Whats the best way to solve this?

 

Many thanks in advance!

1 ACCEPTED SOLUTION
ppm1
Solution Sage
Solution Sage

Please try this syntax instead.

 

= Json.Document(Web.Contents("https://myurl.com/visits?startDate=" & Date.ToText(Date.AddYears(Date.From(DateTime.LocalNow()), -1), "yyyy-MM-dd") & "&limit=500"))

 

Pat

Microsoft Employee

View solution in original post

4 REPLIES 4
ppm1
Solution Sage
Solution Sage

Please try this syntax instead.

 

= Json.Document(Web.Contents("https://myurl.com/visits?startDate=" & Date.ToText(Date.AddYears(Date.From(DateTime.LocalNow()), -1), "yyyy-MM-dd") & "&limit=500"))

 

Pat

Microsoft Employee

Thank you!

ouaelaam
Resolver I
Resolver I

Hi,

In your formula try replacing DateTime.LocalNow to DateTime.LocalNow().

Hi,

that was one of my mistakes, thanks!

Helpful resources

Announcements
FabCon Global Hackathon Carousel

FabCon Global Hackathon

Join the Fabric FabCon Global Hackathon—running virtually through Nov 3. Open to all skill levels. $10,000 in prizes!

October Power BI Update Carousel

Power BI Monthly Update - October 2025

Check out the October 2025 Power BI update to learn about new features.

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 Kudoed Authors