Forum Discussion

santidlp65's avatar
santidlp65
New Member
2 years ago

Dinamyc Source for web service

Hello im using a web service, and the web service requires to put a start date and end date of the data you want consult in the web service. The following is the url that i need to be dynamic;

 

https://xxxxxxxxxxxx/ws/wstrack2.asmx/GetSessionByDateRange?SecurityToken=xxxxxxxxxxx&StartDate=2023-01-01 00:00:00&EndDate=2024-03-01 00:00:00"

 

So for example i want it show the last two years of data always. So it would be somthing like that;

EndDate = today date

StartDate = today date - 2 years

 

how can i do this?

2 Replies

  • Anonymous's avatar
    Anonymous
    Not applicable

    Hi santidlp65 ,

    lbendlin Thanks for your concern about this case!

    Have you solved your problem? If not, please try this M function:

    let
        CurrentDate = DateTime.LocalNow(),
        StartDate = Date.AddYears(CurrentDate, -2),
        EndDate = CurrentDate,
        FormattedStartDate = Date.ToText(StartDate, "yyyy-MM-dd HH:mm:ss"),
        FormattedEndDate = Date.ToText(EndDate, "yyyy-MM-dd HH:mm:ss"),
        SourceURL = "https://xxxxxxxxxxxx/ws/wstrack2.asmx/GetSessionByDateRange?SecurityToken=xxxxxxxxxxx&StartDate=" & FormattedStartDate & "&EndDate=" & FormattedEndDate
    in
        SourceURL

    This M function dynamically generates the URL with StartDate and EndDate based on the current date.

    Best Regards,
    Dino Tao
    If this post helps, then please consider Accept it as the solution to help the other members find it more quickly.