Google-sheets – Can you change the importhtml address for the website URL automatically? The website address ends in tomorrows date so changes each day

google sheetsimporthtml

Using importhtml, I always access tomorrows updated data from a website which finishes the webpage address with tomorrows date. Is there a way of automatically updating that part of the address each day so that it will continue to import tomorrows data?

e.g. : https://www.poisonfoot.com/30-12-2020/

=importhtml("https://www.poisonfoot.com/30-12-2020/","table",0)

Best Answer

I think this is what @Rubén was getting at. This formula will automatically change to reflect the current date:

="https://www.poisonfoot.com/"&day(TODAY())&"-"&month(TODAY())&"-"&year(TODAY())&"/"

Value = https://www.poisonfoot.com/31-12-2020/


Snapshot


Leading zeros

The values of day, month and year in the web address are taken from values; the result is that leading zeros that might appear in TODAY() are lost when combined in the web address.

The alternative is to convert the values to text and format them. In this solution, I used TEXT() and the format of dd/mm/yyyy (forcing leading zeros).

="https://www.poisonfoot.com/"&left(text(today(),"dd/mm/yyyy"),2)&"-"&mid(text(today(),"dd/mm/yyyy"),4,2)&"-"&mid(text(today(),"dd/mm/yyyy"),7,4)&"/"

Value = https://www.poisonfoot.com/04-01-2021/


Alternate with leading zeros