I am trying to download stock data using an api, and for the api to work I need to request the date in the YYYYMMDD format, however I would like it to output YYYY-MM-DD.
Currently I am using this code to request the data:
write(symbol, ";", exchange, ";", bar.date.replace(' ', '; '), ";", bar.open, ";", bar.high, ";", bar.low, ";", bar.close, ";", bar.volume)
Since the API gives me the output: "YYYYMMDD HH:MM:SS", I have already used the command .replace(' ', '; '), so that it puts a semicolon behind the date output. Now i also would like to format the date output to YYYY-MM-DD, but I think because I am using the .replace i cannot seem to find a way to let this work myself.
Could anyone here help me out?