Forum Discussion

Anonymous's avatar
Anonymous
Not applicable
4 years ago
Solved

Import from web - dynamic year today range

Dear All!

I would like to ask for your help with the following case.

 

I have a website to import data from on daily basis.

Importing data from a specific date till today. I have the problem with the today part.

 

deviza=rbCurrencyActual&devizaSelected=ZAR&datefrom=2022.01.01.&datetill=2022.03.13.&order=1
 
 
I highlited the part of the date of today. 
Do you have any recommendation, how can I replace this fix date with a dynamic today formula?
 
I have tried the datetime.localnow funtction converting into text, but with no success.
 
Thank you in davance for your help and support
Best regards
S.
 
 
 
 

6 Replies

  • mahoneypat's avatar
    mahoneypat
    Microsoft Employee

    You can use this expression to get the current date in the needed format. You can either concatenate it into your string, or create it in a separate variable and use that.

     

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

     

    Pat

    • Anonymous's avatar
      Anonymous
      Not applicable

      Hi mahoneypat !

      The "yyyy.MM.dd" part is giving me a Token Comma Expected error.

      Any idea, what might have gone worng?

      Thank you

      S

      • mahoneypat's avatar
        mahoneypat
        Microsoft Employee

        Please post your entire M code from the Advanced Editor. Also, I forgot the last . in your date format but you can easily add that.

         

        Pat