# Dates DateTime parse string with microseconds (decimal 6 places)

**URL:** https://discourse.julialang.org/t/dates-datetime-parse-string-with-microseconds-decimal-6-places/25653
**Category:** General Usage
**Tags:** dates
**Created:** [June 25, 2019, 2:05pm UTC](https://discourse.julialang.org/t/dates-datetime-parse-string-with-microseconds-decimal-6-places/25653 "2019-06-25T14:05:02Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![Joshua\_Bowles](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/joshua_bowles/32/4515_2.png) [@Joshua\_Bowles](https://discourse.julialang.org/u/Joshua_Bowles)
#### Post date: [June 25, 2019, 2:05pm UTC](https://discourse.julialang.org/t/dates-datetime-parse-string-with-microseconds-decimal-6-places/25653/1 "2019-06-25T14:05:02Z")

</div>

I’ve got files to import with postgres formatted timestamps to the microseconds (6 digits). I’m unable to find the proper date format. I’ve looked through Dates/test/io.jl as well in this forum. Curious if I’m missing something.

I’ll likely just truncate the string and use the millisecond formatting if I can’t find the microsecond parsing format.

```julia
import Dates
## need formatting for microseconds μ
#https://github.com/JuliaLang/julia/blob/master/stdlib/Dates/test/io.jl
t1 = "2019-06-23 14:14:35.400963"
df1 = Dates.DateFormat("yyyy-mm-dd HH:MM:SS.s")
Dates.parse_components(t1, df1)
# ERROR: InexactError: convert(Dates.Decimal3, 400963)

df2 = Dates.DateFormat("yyyy-mm-dd HH:MM:SS.sss")
Dates.DateTime(t1, df2)
# ERROR: InexactError: convert(Dates.Decimal3, 400963)

df3 = Dates.DateFormat("yyyy-mm-dd HH:MM:SS.ssssss")
Dates.DateTime(t1, df3)
# ERROR: InexactError: convert(Dates.Decimal3, 400963)

```

I’ve verified the parsing works if I either remove the microseconds or truncate to 3 decimal places.

```julia
df4 = Dates.DateFormat("yyyy-mm-dd HH:MM:SS")
t2 = "2019-06-23 14:14:35"
Dates.DateTime(t2, df4)
#2019-06-23T14:14:35

t3 = "2019-06-23 14:14:35.400"
Dates.DateTime(t3, df2)
#2019-06-23T14:14:35.4

```

---

<div class="post-metadata">

### Author: ![Simon\_Parten](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/simon_parten/32/20656_2.png) [@Simon\_Parten](https://discourse.julialang.org/u/Simon_Parten)
#### Post date: [December 30, 2020, 9:01am UTC](https://discourse.julialang.org/t/dates-datetime-parse-string-with-microseconds-decimal-6-places/25653/2 "2020-12-30T09:01:15Z")

</div>

Did you ever get a response to this? I have the same problem…

---

<div class="post-metadata">

### Author: ![Sukera](https://avatars.discourse-cdn.com/v4/letter/s/ce7236/32.png) [@Sukera](https://discourse.julialang.org/u/Sukera)
#### Post date: [December 30, 2020, 10:14am UTC](https://discourse.julialang.org/t/dates-datetime-parse-string-with-microseconds-decimal-6-places/25653/3 "2020-12-30T10:14:10Z")

</div>

`DateTime` only supports resolution up to millisecond precision, as it’s basically a wrapper around `UTInstant{Millisecond}`. See [here](https://docs.julialang.org/en/v1/stdlib/Dates/#Dates.DateTime).

If you need higher precision, it’s probably enough to split the string into a `Date` and `Time` component, as `Time` supports `Nanosecond` precision on a 24-hour day.

---

<div class="post-metadata">

### Author: ![onetonfoot](https://sea2.discourse-cdn.com/julialang/user_avatar/discourse.julialang.org/onetonfoot/32/2697_2.png) [@onetonfoot](https://discourse.julialang.org/u/onetonfoot)
#### Post date: [January 7, 2022, 9:48am UTC](https://discourse.julialang.org/t/dates-datetime-parse-string-with-microseconds-decimal-6-places/25653/4 "2022-01-07T09:48:11Z")

</div>

You can use [TimesDates](https://jeffreysarnoff.github.io/TimesDates.jl/latest/setup/)

```julia
using TimesDates

TimeDate("2022-01-07T09:30:21.383895100")

```
