# Robust date conversion from string to DateTime

**URL:** <https://discourse.julialang.org/t/robust-date-conversion-from-string-to-datetime/87215>\
**Category:** Data\
**Created:** [September 13, 2022, 1:40pm UTC](https://discourse.julialang.org/t/robust-date-conversion-from-string-to-datetime/87215 "2022-09-13T13:40:55Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![scotts](https://avatars.discourse-cdn.com/v4/letter/s/ac8455/32.png) [@scotts](https://discourse.julialang.org/u/scotts)\
**Post date:** [September 13, 2022, 1:40pm UTC](https://discourse.julialang.org/t/robust-date-conversion-from-string-to-datetime/87215/1 "2022-09-13T13:40:55Z")

</div>

I am having to convert dates in the following string format “24/9/2020” to DateTime format. DateTime does not deal with this basic format.

I have come up with the following solution that does this for the data I’m dealing with (all dates in this millennium), but I am sure there is batter way:

```julia
Reg.date_project_registered = replace.(Reg.date_project_registered,"/20"=>"-") #date format converions
Reg.date_project_registered = replace.(Reg.date_project_registered,"/"=>"-")
Reg.date_project_registered = DateTime.(Reg.date_project_registered)

```

Is there a better way?

---

<div class="post-metadata">

**Author:** ![Palli](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/palli/32/3380_2.png) [@Palli](https://discourse.julialang.org/u/Palli)\
**Post date:** [September 13, 2022, 2:01pm UTC](https://discourse.julialang.org/t/robust-date-conversion-from-string-to-datetime/87215/2 "2022-09-13T14:01:47Z")

</div>

Y-M-D date format is just the default. You can parse a DMY date format as explained in the docs (and I suppose to get out in same format too somehow):

```julia
julia> using Dates
julia> Date("24/9/2020", dateformat"d/m/y")
2020-09-24

```
