Dynamically saving a CSV file as yesterday's date

Hello,

I’m in the process of building a bot and I am writing a data table to a csv file but I want to the file name to be saved dynamically as yesterday’s date.

So for example if I ran the bot today the file name should be “1-4-22”. I used the assign and write CSV function as you will se below but currently it’s producing a file name not in a date format. When I ran it yesterday the result was a file name of 03-54-22.

I’ve created a string variable for fileName and my function within the assign is - now.AddDays(-1).ToString(“dd-m-yy”)

image

Any help would be appreciated!

1 Like

@Kevin_Legendre

Try as dd-MM-yy instead of dd-m-yyy

m refers to Minutes

MM refers to Month

Hope this may help you

Thanks

1 Like

@Kevin_Legendre

For Reference check below

Date Reference

Hope this may help you

Thanks

@Kevin_Legendre

Check below

image

Thanks

Hello @Kevin_Legendre,

Maybe you can try this: DateTime.Today.AddDays(-1).ToString(“dd-MM-yy”)

I hope it helps you :slight_smile:

1 Like

@Srini84 that worked, thank you for the help!

1 Like

This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.