我将xml文件导入excel,日期格式为yyyy-MM-ddTHH:mm:ssZ,如何将格式更改为yyyyy-mm-dd HH:MM:ss还是Unix格式?
谢谢!
答案 0 :(得分:0)
转到你的excel并执行此操作
search for ur format type and done
更新1:好的,试试
relationship()
根据需要更改代码
更新2:尝试
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
答案 1 :(得分:0)
可以使用以下函数更改字符串“ yyyy-MM-ddTHH:mm:ssZ”的日期оr,以将“ T”替换为“”,将“ Z”替换为“”
Function StrToDate(str As String) As Date
StrToDate = CDate(Replace(Replace(str, "T", " "), "Z", ""))
End Function