# Unable to parse julia date \[duyyyy\]

**URL:** <https://discourse.julialang.org/t/unable-to-parse-julia-date-duyyyy/50080>\
**Category:** General Usage\
**Tags:** question, dates\
**Created:** [November 13, 2020, 4:40am UTC](https://discourse.julialang.org/t/unable-to-parse-julia-date-duyyyy/50080 "2020-11-13T04:40:36Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![Rodrigo\_Zepeda](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rodrigo_zepeda/32/17935_2.png) [@Rodrigo\_Zepeda](https://discourse.julialang.org/u/Rodrigo_Zepeda)\
**Post date:** [November 13, 2020, 4:40am UTC](https://discourse.julialang.org/t/unable-to-parse-julia-date-duyyyy/50080/1 "2020-11-13T04:40:37Z")

</div>

I am trying to read dates in the format such as “09Aug2015”. From my understanding of datetime objects the format is `duyyyy`. In fact when converting a date to that format it looks quite like what I want:

```julia
date_august = Dates.format(now(), DateFormat("duyyyy"))

```

However, when trying to read back the date I get an error:

```julia
Date(string(date_august),DateFormat("duyyyy"))

```

```julia
ERROR: ArgumentError: Unable to parse date time. Expected directive DatePart(u) at char 2
Stacktrace:
 [1] macro expansion at /Applications/Julia-1.5.app/Contents/Resources/julia/share/julia/stdlib/v1.5/Dates/src/parse.jl:104 [inlined]
 [2] tryparsenext_core(::String, ::Int64, ::Int64, ::DateFormat{:duyyyy,Tuple{Dates.DatePart{'d'},Dates.DatePart{'u'},Dates.DatePart{'y'}}}, ::Bool) at /Applications/Julia-1.5.app/Contents/Resources/julia/share/julia/stdlib/v1.5/Dates/src/parse.jl:38
 [3] macro expansion at /Applications/Julia-1.5.app/Contents/Resources/julia/share/julia/stdlib/v1.5/Dates/src/parse.jl:150 [inlined]
 [4] tryparsenext_internal at /Applications/Julia-1.5.app/Contents/Resources/julia/share/julia/stdlib/v1.5/Dates/src/parse.jl:125 [inlined]
 [5] parse at /Applications/Julia-1.5.app/Contents/Resources/julia/share/julia/stdlib/v1.5/Dates/src/parse.jl:282 [inlined]
 [6] Date(::String, ::DateFormat{:duyyyy,Tuple{Dates.DatePart{'d'},Dates.DatePart{'u'},Dates.DatePart{'y'}}}) at /Applications/Julia-1.5.app/Contents/Resources/julia/share/julia/stdlib/v1.5/Dates/src/io.jl:503
 [7] top-level scope at none:1

```

Any ideas on how am I to read those kinds of dates? Thks!

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [November 13, 2020, 7:53am UTC](https://discourse.julialang.org/t/unable-to-parse-julia-date-duyyyy/50080/2 "2020-11-13T07:53:21Z")

</div>

I don’t think anyone will be able to help really unless you turn this into a minimum working example - without knowing what `date_august` is it’s pretty much impossible to tell what’s going wrong.

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [November 13, 2020, 7:56am UTC](https://discourse.julialang.org/t/unable-to-parse-julia-date-duyyyy/50080/3 "2020-11-13T07:56:28Z")

</div>

```julia
julia> date_august = "09Aug2015"
"09Aug2015"

julia> Date(date_august, dateformat"dduuuyyyy")
2015-08-09

```

---

<div class="post-metadata">

**Author:** ![Rodrigo\_Zepeda](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rodrigo_zepeda/32/17935_2.png) [@Rodrigo\_Zepeda](https://discourse.julialang.org/u/Rodrigo_Zepeda)\
**Post date:** [November 13, 2020, 8:01am UTC](https://discourse.julialang.org/t/unable-to-parse-julia-date-duyyyy/50080/4 "2020-11-13T08:01:00Z")

</div>

It is right there in the first line

---

<div class="post-metadata">

**Author:** ![Rodrigo\_Zepeda](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/rodrigo_zepeda/32/17935_2.png) [@Rodrigo\_Zepeda](https://discourse.julialang.org/u/Rodrigo_Zepeda)\
**Post date:** [November 13, 2020, 8:01am UTC](https://discourse.julialang.org/t/unable-to-parse-julia-date-duyyyy/50080/5 "2020-11-13T08:01:48Z")

</div>

So weird that to create it one needs the duyyyy format but to read it one needs uuu

---

<div class="post-metadata">

**Author:** ![fredrikekre](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/fredrikekre/32/1688_2.png) [@fredrikekre](https://discourse.julialang.org/u/fredrikekre)\
**Post date:** [November 13, 2020, 8:05am UTC](https://discourse.julialang.org/t/unable-to-parse-julia-date-duyyyy/50080/6 "2020-11-13T08:05:02Z")

</div>

You can use the same format for output too:

```julia
julia> Dates.format(now(), DateFormat("dduuuyyyy"))
"13Nov2020"

```

The reason the `duyyyy` works when formatting is (I guess) since it is not ambiguous as it is when parsing.

---

<div class="post-metadata">

**Author:** ![nilshg](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/nilshg/32/2283_2.png) [@nilshg](https://discourse.julialang.org/u/nilshg)\
**Post date:** [November 13, 2020, 8:05am UTC](https://discourse.julialang.org/t/unable-to-parse-julia-date-duyyyy/50080/7 "2020-11-13T08:05:18Z")

</div>

Ah, sorry, I see what your issue is now, I somehow thought you had used a different date to read in (maybe because `now()` is November in my time zone 🙂 )
