I'm trying below very simple VBA code to convert to Datetime
Sub datetimedifffference()
Dim d As String
Dim sd As Date
d = "2021-04-06T12:56:16+0000"
sd = Format(CDate(d), "mm-dd-yyyy hh:mm:ss")
Debug.Print sd
End Sub
But it is giving type mismatch error Any help would be highly appreciated
I again tried below, but the difference of time is decreasing instead increasing
Sub datetimedifffference()
Dim d As String
Dim sd As Long
d = "2021-04-06T12:56:16+0000"
sd = DateDiff("n", Now, Format(convertStringtoDate(d))
Debug.Print sd
End Sub
Function convertStringtoDate(stringdate As String) As String
Dim strings() As String
strings = Split(stringdate, "T")
convertStringtoDate = strings(0) & " " & Left(strings(1), 8)
'Debug.Print convertStringtoDate
End Function