I’ve got files to import with postgres formatted timestamps to the microseconds (6 digits). I’m unable to find the proper date format. I’ve looked through Dates/test/io.jl as well in this forum. Curious if I’m missing something.
I’ll likely just truncate the string and use the millisecond formatting if I can’t find the microsecond parsing format.
import Dates
## need formatting for microseconds μ
#https://github.com/JuliaLang/julia/blob/master/stdlib/Dates/test/io.jl
t1 = "2019-06-23 14:14:35.400963"
df1 = Dates.DateFormat("yyyy-mm-dd HH:MM:SS.s")
Dates.parse_components(t1, df1)
# ERROR: InexactError: convert(Dates.Decimal3, 400963)
df2 = Dates.DateFormat("yyyy-mm-dd HH:MM:SS.sss")
Dates.DateTime(t1, df2)
# ERROR: InexactError: convert(Dates.Decimal3, 400963)
df3 = Dates.DateFormat("yyyy-mm-dd HH:MM:SS.ssssss")
Dates.DateTime(t1, df3)
# ERROR: InexactError: convert(Dates.Decimal3, 400963)
I’ve verified the parsing works if I either remove the microseconds or truncate to 3 decimal places.
df4 = Dates.DateFormat("yyyy-mm-dd HH:MM:SS")
t2 = "2019-06-23 14:14:35"
Dates.DateTime(t2, df4)
#2019-06-23T14:14:35
t3 = "2019-06-23 14:14:35.400"
Dates.DateTime(t3, df2)
#2019-06-23T14:14:35.4