简体   繁体   English

Excel VBA-更改日期格式

[英]Excel vba - change format of date

I have a column with dates that are stored as dmyyyy. h:mm:ss 我有一列的日期存储为dmyyyy. h:mm:ss dmyyyy. h:mm:ss . dmyyyy. h:mm:ss

And the cell format isn't even date it's general . 和单元格的格式更是连日期一般 To use it as a date I need to replace that dot with "" . 要将其用作日期,我需要将该点替换为"" So I used this code: 所以我用了这段代码:

Format(Date, "d.m.yyyy h:mm:ss")

But it changed all dates to todays date. 但是它将所有日期更改为今天。

The call of Date returns the current date. Date调用返回当前日期。 You have to use the cell value instead, like Format(Cells(row,column), "dmyyyy h:mm:ss") , after you replaced the dot at the end of the year value. 在年末值替换点后,必须改用像Format(Cells(row,column), "dmyyyy h:mm:ss")这样的Format(Cells(row,column), "dmyyyy h:mm:ss")值。

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM