Excel date conversion

excel

#1

I have a column in excel with JUN-2018, AUG-2018, etc. They are not in a specific format. I need to change the format to dd/mm/yyyy. How can i do that?


#2

Hi @qaz1, if you have the day available, you could do this.

Date.ParseExact(“DateString”, “dd/mm/yyyy”,System.Globalization.DateTimeFormatInfo.InvariantInfo)


#3

Hi ,

JUN-2018, AUG-2018 - you mentioned only month and year … Date?

without mentioning the date how can we able to convert it into dd/mm/yyyy format


#4

so the date would just be 01-06-2018


#5

the day isnt available but it would be defaulted to 01-06-2018


#6

you can use this code to change any format… try this
DateTime.FromOADate(Convert.ToDouble((Dt.rows(0)(16).ToString))).ToString(“dd-MM-yyyy”)


#7

but date should be mentioned… else it throws error.


#8

Hi @qaz1, first you have to append the day to your date string.

DateString = String.Concat(“01-”,“AUG-2018”)

Then you can convert to your desired format.

Date.ParseExact(DateString,“dd-MMM-yyyy”,System.Globalization.DateTimeFormatInfo.InvariantInfo).ToString(“dd/MM/yyyy”)

Hope this helps. Cheers.


#9