I’ll regularly get an extract from a DB/2 database with dates and timestaps formatted like this:
2002-01-15-00.00.00.000000 2008-01-05-12.36.05.190000 9999-12-31-24.00.00.000000
Is there an easier way to convert this into the Excel date format than decomposing with substrings?
DB2date = DateValue(Left(a, 4) + '/' + Mid(a, 6, 2) + '/' + Mid(a, 9, 2))
thanks for your help!
It’s not clear if you talk about formula functions or VBA functions.
Formula functions
Don’t use the DateValue function, which expects a string; use the Date function, which expects numeric Year, Month, Day:
assuming that the date-as-string is in A1.
VBA functions
Similar calculation as above, just use the DateSerial function instead: