0

I have an Excel 2000 file with around 25 columns. In column18 the column name is "MONTH" and its data type is Date Time. The value is displayed as (1/5/2009) in format(dd/mm/yyyy).

I need to change its data type to string and display the data in this format: (01-05-2010).

Can anyone tell me how to change the data type and change the way we display the data?

pnuts
  • 58,317
  • 11
  • 87
  • 139
happysmile
  • 7,537
  • 36
  • 105
  • 181

1 Answers1

0
  1. read the cell value
  2. depending on a number of factors, the datatype in .net will either be DateTime, string, or double.
  3. if type is not DateTime, then convert to DateTime. If string, then simply DateTime.Parse(), if double then use function here
  4. Convert DateTime to string with desired format. DateTime.ToString("yyyy'-'MM'-'dd"). This is a good resource for formatting dates.
  5. Set the cell's value to this string value.
Suraj
  • 35,905
  • 47
  • 139
  • 250