Set index! not defined for WeakRefStrings. SpringArray{String,1}

i wanted to create a loop on a column in my IJulia and I came up with this error. Please what can I do to retify it.

Here is my code:
for v=1:length(col1)
col1[v] = Dates.DateTime(col1[v], “d-u-y”)
end

And I got this error:
setindex! not defined for WeakRefStrings.StringArray{String,1}

Stacktrace:
[1] error(::String, ::Type{T} where T) at .\error.jl:42
[2] error_if_canonical_setindex(::IndexLinear, ::WeakRefStrings.StringArray{String,1}, ::Int64) at .\abstractarray.jl:1081
[3] setindex!(::WeakRefStrings.StringArray{String,1}, ::DateTime, ::Int64) at .\abstractarray.jl:1072
[4] top-level scope at .\In[130]:2

I decided to try changing the code a little bit using:
i in col1
global col1[i] = Dates.DateTime(string.(col1[i]), “d-u-y”)
end

Then I still got this error;:
ArgumentError: invalid index: “4-Jul-2014” of type String

Stacktrace:
[1] to_index(::String) at .\indices.jl:297
[2] to_index(::WeakRefStrings.StringArray{String,1}, ::String) at .\indices.jl:274
[3] to_indices at .\indices.jl:325 [inlined]
[4] to_indices at .\indices.jl:322 [inlined]
[5] getindex(::WeakRefStrings.StringArray{String,1}, ::String) at .\abstractarray.jl:980
[6] top-level scope at .\In[136]:2

I’m not 100% since you didn’t show how you where initialize col1…So I can’t test anything. But it appears that col1 is a Vector of Strings since you are passing the value of DateTime(), however you are also trying to set col1 to the DateTime structure that is being returned from the function.

So you are basically trying to change the type from String to DateTime. My guess is that is the issue. Was col1 initialize as an array of Any or as an Array of Strings?

Here is a screenshot of the col1 initiation.

Okay, so that is an array of strings, so you could do something like:

col1dt = Vector{Dates.DateTime}(undef, length(col1))
for v = 1:length(col1)
    col1dt[v] = Dates.DateTime(col1[v], "d-u-y")
end

Then all your DateTime objects will be in col1dt

It worked. Thank you very much