How to concatenate & format 2 date fields into 1 cell

Hi, I am trying to put the text "4/1/2007 through 5/15/2007" on the header of my excel report. I need some help getting it to format the dates correctly. My code looks like this:

Cells(startRow + 2, 8).PutValue(CType(dt.Rows(0)("Date1"), Date)) 'this is the field for the 1st date 4/1/2007

Cells(startRow + 2, 9).PutValue(CType(dt.Rows(0)("Date2"), Date)) 'this is the field for the 2nd date 5/15/2007

Cells(startRow + 2, 10).PutValue(" through ")

Cells(startRow + 2, 8).Style = style4 'syle 4 is the date format type

Cells(startRow + 2, 9).Style = style4

Cells(startRow + 2, 2).Formula = "=CONCATENATE(I4,K4,J4)" 'here I am concatenating all 3 columns

The result looks like this: "39173 through 39217".

Can you please help me with formatting the dates correctly in the result? Thanks!

Hi,

Thanks for considering Aspose.

Well, Dates are rendered into numbers values by default. I think you can replace a line in your code as follows:

Cells(startRow + 2, 8).PutValue(CType(dt.Rows(0)("Date1"), Date)) 'this is the field for the 1st date 4/1/2007

Cells(startRow + 2, 9).PutValue(CType(dt.Rows(0)("Date2"), Date)) 'this is the field for the 2nd date 5/15/2007

Cells(startRow + 2, 10).PutValue(" through ")

Cells(startRow + 2, 8).Style = style4 'syle 4 is the date format type

Cells(startRow + 2, 9).Style = style4

cells(startRow + 2, 2).PutValue(cells("I4").StringValue + cells("K4").StringValue + cells("J4").StringValue) 'here I am concatenating all 3 columns

Thank you.