# Convert Date Values to Dates.DateTime

I have date information coming from a sensor thats formatted as i = 8304.621828703705. Is there a way to easily convert this to a DateTime? I can get a Date (yy-mm-dd) out of it using Date(Dates.UTD(round(i))), however I really need a DateTime (yyyymmdd HHMMSS).

There are likely to be more direct and idiomatic ways of accomplishing this, but see if the following lines inspire you.

``````julia> t=now()
2023-03-04T18:56:54.720

julia> Dates.value(t)
63813639414720

julia> Dates.UTM(Dates.value(t))
Dates.UTInstant{Millisecond}(Millisecond(63813639414720))

julia> DateTime(Dates.UTM(Dates.value(t)))
2023-03-04T18:56:54.720

julia> round(Dates.value(t)/(1000*24*60*60))
738584.0

julia> Dates.UTD(round(Dates.value(t)/(1000*24*60*60)))
Dates.UTInstant{Day}(Day(738584))

julia> Date(Dates.UTD(Dates.value(t)))
174715810495-12-31
``````
``````
i = 8304.621828703705  # if these are days, in milliseconds they do

DateTime(Dates.UTInstant(Dates.Millisecond(round(i*1000*24*60*60)))) # 0023-09-26T14:55:26
# maybe floor instead round is better

round(i*1000*24*60*60) ≈ Dates.value(DateTime("0023-09-26T14:55:26")) #true
``````

The conversion in the last part did the Trick, thanks!