Forum Discussion

Madhu155154's avatar
Madhu155154
Helper I
3 years ago
Solved

How to change static date to dynamic date in API, for refreshing data - to current date

Any suggestion on how to change the "end date" from static to "dynamic to the (current) Present date" for capturing the data till the current date, while refreshing it,

Data - I got the data through the API


Current Issue - I am changing the end date manually in the Power Query 




 

 

 

  • I have used the below formula to get the date and  then passed it as a parameter in API, But Thank you for your support and suggestion 

    currentDate = Date.ToText(DateTime.Date(DateTime.LocalNow()), "yyyy-MM-dd"),


    let

    currentDate = Date.ToText(DateTime.Date(DateTime.LocalNow()), "yyyy-MM-dd"),


    Source = Json.Document(Web.Contents("https://cs-intmgroservices.io/intmgmtsvc/report/nReport" & "?startDt=2020-01-01&endDt=currentDate",



6 Replies

  •  Mahesh0016  , Thank you for replying.

    I I, have used  your suggested function in the power query, but  i am getting an error

    • Mahesh0016's avatar
      Mahesh0016
      Super User

      @Please Try this. Thank You.
      endDt
      = #date(
      Date.Year(DateTime.Date(DateTime.LocalNow())),
      Date.Month(DateTime.Date(DateTime.LocalNow())),
      Date.Day(DateTime.Date(DateTime.LocalNow()))
      )

      • Madhu155154's avatar
        Madhu155154
        Helper I

          I have used  your suggested function in the power query, but  still I am getting an error

  • I have used the below formula to get the date and  then passed it as a parameter in API, But Thank you for your support and suggestion 

    currentDate = Date.ToText(DateTime.Date(DateTime.LocalNow()), "yyyy-MM-dd"),


    let

    currentDate = Date.ToText(DateTime.Date(DateTime.LocalNow()), "yyyy-MM-dd"),


    Source = Json.Document(Web.Contents("https://cs-intmgroservices.io/intmgmtsvc/report/nReport" & "?startDt=2020-01-01&endDt=currentDate",