开发者

Change the column value data type (dates)

I have an Excel 2000 file with around 25 columns. In column18 the column name is "MONTH" and its data开发者_StackOverflow 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?


  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.
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜