Xml 在Excel中将yyyy-MM-ddTHH:MM:ssZ日期转换为yyyy-MM-dd-HH:MM:ss
我将xml文件导入excel,日期格式为yyyy-MM ddTHH:MM:ssZ,如何将格式更改为yyyy-MM-dd HH:MM:ss或Unix格式Xml 在Excel中将yyyy-MM-ddTHH:MM:ssZ日期转换为yyyy-MM-dd-HH:MM:ss,xml,excel,Xml,Excel,我将xml文件导入excel,日期格式为yyyy-MM ddTHH:MM:ssZ,如何将格式更改为yyyy-MM-dd HH:MM:ss或Unix格式 谢谢 转到您的excel并执行此操作 更新1:好的,试试看 Sub ChangeDateFormat() Application.ScreenUpdating = False Dim CurrentCell As Range Dim LastRow As Long Dim RegEx As Object Set RegEx = Creat
谢谢 转到您的excel并执行此操作 更新1:好的,试试看
Sub ChangeDateFormat()
Application.ScreenUpdating = False
Dim CurrentCell As Range
Dim LastRow As Long
Dim RegEx As Object
Set RegEx = CreateObject("vbscript.regexp")
RegEx.Global = True
LastRow = Range("A" & Rows.Count).End(xlUp).Row 'Get The Last Row in Column Change A as Needed
For Each CurrentCell In Range("A1:A" & LastRow) ' Loop through all cells. Change Column as needed
If InStr(CurrentCell.Value, "/") <> 0 Then 'To make sure only convert non converted ones
RegEx.Pattern = "(\d{4})/(\d{2})/(\d{4}) (\d{2}):(\d{2}):(\d{2})" ' Seperate all parts of imported Data into groups
CurrentCell.Value = RegEx.Replace(CurrentCell.Value, "$3.$2.$1 $4:$5") ' Change order of groups and place into cell.
End If
Next
Application.ScreenUpdating = True
End Sub
format(now(), "yyyy-MM-dd hh:mm:ss")
字符串“yyyy-MM-ddTHH:MM:ssZ”可以通过以下函数更改为日期,以将“T”替换为“”,将“Z”替换为“”
单击查看图像我更改了格式,但没有更改任何内容。此外,我尝试了=TEXT(单元格;“yyy-mm-aa-HH:mm:ss”),但第一次使用宏时没有成功:(.该代码是否位于A列?无法生成仅宏的写入格式(现在(),“yyy-mm-dd-HH:mm:ss”),我应该添加更多代码吗?我尝试了:函数GetDateFormatted(mydate为Date)GetDateFormatted=format(mydate,“yyyy-dd-mm-HH:mm”)结束函数并返回#值
Function StrToDate(str As String) As Date
StrToDate = CDate(Replace(Replace(str, "T", " "), "Z", ""))
End Function