开发者

Excel datevalue

开发者 https://www.devze.com 2023-04-11 01:05 出处:网络
How do I convert a date string 2019-06-20T00:00:00+01:00 to an Excel date? D开发者_JAVA百科ATEVALUE returns #Value when I try this in Excel.

How do I convert a date string 2019-06-20T00:00:00+01:00 to an Excel date? D开发者_JAVA百科ATEVALUE returns #Value when I try this in Excel.

The date string comes from C# DateTime ToShortDateString()


Instead of ToShortDateString() use ToOADate().

Format the cell as Date and you should be all set.


In Excel you could just take everything to the left of the T character. If that date string was in cell A1 then:

=DATEVALUE(LEFT(A1,FIND("T",A1)-1))

Alternatively in VBA if the date string was stored in a variable called sFoo:

CDate(Left$(sFoo,Instr(sFoo,"T")-1))
0

精彩评论

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