Issue while creating excel file in google share drive

Hi All, I want to create excel files dynamically for each day run in google share drive. For example my excel file path looks like this : G:\Shared drives\Bot_Output\process_24062020.xlsx and here in place of date i’m passing date.now.tostring
But the problem is some time i am getting excel file name like this G:\Shared drives\Bot_Output\55DC6200(It means it is not creating excel with date, instead of date it is creating with some random numbers)
Please help.

Hi @Farook1
Try
Now.ToString("MM/dd/yyyy")

1 Like

hi codenameCata,

i think FileName = "process_" + DateTime.Now.ToString("MMddyyyy") + ".xlsx"
file name is not support ‘/’

thanks

1 Like

Yes, that’s accurate. Thanks for pointing out. :slight_smile:

@codenameCata and @nguyendinhduc269 can you please tell me what is the difference between those two methods date.now.tostring and DateTime.Now.ToString(“MMddyyyy”).
The reason am asking is because my bot is creating excel file with date extension succesfully, but only once in months or twice it has created like this G:\Shared drives\Bot_Output\55DC6200 with random numbers. Now please help me how can i make this not to happen again???

@Farook1
Date.Now and DateTime.Now are the same.
If you point your mouse at the keyword Date, it will show that it’s actually System.DateTime class (as shown below)

image
The String argument “MMddyyyy” in the ToString method helps get the string in a desired dateformat.

As far as your issue is concerned, can you please share the relevant parts of your code?
Where is your input coming from? Are you always using Date.Now or is there a date being passed from somewhere instead of Now ?

Thanks.