How to get the date in "MM/dd/yyyy" format while reading from excel sheet


#1

Hi All,

I am reading date from the excel sheet. While reading I am getting that date in “MM/dd/yyyy 00:00:00”. But I want that date in "MM/dd/yyyy? Format.

Can you all please help me with this.

Thanks and Regards,
Ananthaeswar.


#2

If it is recognised as date then simply use date.parse method and select the output “MM/dd/yyyy” else if it is string trim the first 10 characters and then do the same thing. Worth running it through date.tryparse and date.parse anyway to ensure it is formatted correctly, e.g. not a US date which Excel often likes to do.

You can search date functions on MSDN for examples.


#3

Hello @Ananthaeswar2,

could you please send/attach excel file?

Thanks,
Pankaj