Converting columns in a DataFrame from String to Date (with a specific format)

Parsing into a Date is done by:

julia> d1="02/02/2022"
"02/02/2022"

julia> date=Date(d1,"dd/mm/yyyy")
2022-02-02

julia> typeof(date)
Date

Output (as String) is done by:

julia> s=Dates.format(date,"Ymmdd")
"20220202"

So:

A[!,:DATE]= Dates.format.(Date.( A[!,:DATE],"dd/mm/yyyy"),"Ymmdd")

Typically, when it’s about DataFrames, after a while, much more elegant versions are popping up, just wait for it…

2 Likes