# How to convert to DateTime all column or array?

**URL:** <https://discourse.julialang.org/t/how-to-convert-to-datetime-all-column-or-array/2421>\
**Category:** New to Julia\
**Tags:** dates, convert\
**Created:** [March 3, 2017, 10:30am UTC](https://discourse.julialang.org/t/how-to-convert-to-datetime-all-column-or-array/2421 "2017-03-03T10:30:03Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [March 3, 2017, 10:30am UTC](https://discourse.julialang.org/t/how-to-convert-to-datetime-all-column-or-array/2421/1 "2017-03-03T10:30:04Z")

</div>

How to convert to DateTime all column or array ?  
julia\> events  
10×2 Array{Int64,2}:  
63595231244000 63595306875000  
63595195227000 63595201258000  
63595205030000 63595218561000  
63595182573000 63595195258000  
63595234425000 63595235057000  
63595234424000 63595256055000  
63595162792000 63595375222000  
63595214798000 63595214828000  
63595215154000 63595215184000  
63595214698000 63595214728000

julia\> convert(DateTime, events[1,2])  
2016-04-02T19:01:15

julia\> convert(DateTime, events[:,2])  
ERROR: MethodError: Cannot `convert` an object of type Array{Int64,1} to an object of type DateTime  
This may have arisen from a call to the constructor DateTime(…),  
since type constructors fall back to convert methods.

julia\> convert.(DateTime, events[:,2])  
ERROR: MethodError: no method matching size(::Type{DateTime})  
Closest candidates are:  
size{N}(::Any, ::Integer, ::Integer, ::Integer…) at abstractarray.jl:48  
size(::BitArray{1}) at bitarray.jl:39  
size(::BitArray{1}, ::Any) at bitarray.jl:43  
…  
in broadcast\_shape(::Type{T}, ::Array{Int64,1}) at .\broadcast.jl:31  
in broadcast\_t(::Function, ::Type{Any}, ::Type{T}, ::Vararg{Any,N}) at .\broadcast.jl:213  
in broadcast(::Function, ::Type{T}, ::Array{Int64,1}) at .\broadcast.jl:230  
Paul

---

<div class="post-metadata">

**Author:** ![Daneel](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/daneel/32/175_2.png) [@Daneel](https://discourse.julialang.org/u/Daneel)\
**Post date:** [March 3, 2017, 10:48am UTC](https://discourse.julialang.org/t/how-to-convert-to-datetime-all-column-or-array/2421/2 "2017-03-03T10:48:41Z")

</div>

I think `convert.` should work in Julia 0.6 but if you want something that’ll work in Julia 0.5 then this will work:

`map((x) -> convert(DateTime,x),events[:,2])`

---

<div class="post-metadata">

**Author:** ![programista](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/programista/32/5372_2.png) [@programista](https://discourse.julialang.org/u/programista)\
**Post date:** [March 3, 2017, 12:32pm UTC](https://discourse.julialang.org/t/how-to-convert-to-datetime-all-column-or-array/2421/3 "2017-03-03T12:32:58Z")

</div>

Thx, very nice!

---

<div class="post-metadata">

**Author:** ![Mattriks](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/mattriks/32/351_2.png) [@Mattriks](https://discourse.julialang.org/u/Mattriks)\
**Post date:** [March 3, 2017, 4:39pm UTC](https://discourse.julialang.org/t/how-to-convert-to-datetime-all-column-or-array/2421/4 "2017-03-03T16:39:40Z")

</div>

or

```julia
convert(Array{DateTime},events)

```
