Forum Discussion
Passing dynamic date parameters to Web query
- 9 years ago
= Csv.Document(Web.Contents("https://reports.xxxxx.net/generate.py/ProcessedTxnsRecon.csv?StartDate="&Text.Combine(List.Transform(Record.FieldValues(Date.ToRecord(Date.From(DateTime.LocalNow()))), each Text.PadStart(Text.From(_), 2, "0")))&"&EndDate="&Text.Combine(List.Transform(Record.FieldValues(Date.ToRecord(Date.AddMonths(Date.From(DateTime.LocalNow()),-MonthParameter))), each Text.PadStart(Text.From(_), 2, "0")))& ""),[Delimiter=",", Columns=43, Encoding=1252, QuoteStyle=QuoteStyle.None])
with
Hi gingercat123 ,
sure - you have to use the "-" as a delimiter in the 2nd function argument of Text.Combine:
TodaysDate
Text.Combine(List.Transform(Record.FieldValues(Date.ToRecord(Date.From(DateTime.LocalNow()))), each Text.PadStart(Text.From(_), 2, "0")), "-")
FromDate:
= Text.Combine(List.Transform(Record.FieldValues(Date.ToRecord(Date.AddMonths(Date.From(DateTime.LocalNow()),-<<YourParameter>>))), each Text.PadStart(Text.From(_), 2, "0")),"-")
Thanks Imke, If i would want to use this code dynamically , to fetch the data for past 12 months is that possible, api link will allow me to download data for only 30 days max, can i run in loop