gjh
April 20, 2022, 2:30pm
1
Thank you for any help with this. When I convert this string to Date I get the below format. What am I doing wrong? Why can’t I get “yyyy-mm-dd”? Thank you!
using Dates, DataFrames
id = [1, 2, 3, 4, 5]
bday = [“8/23/62”, “12/26/66”, “1/17/62”, “12/30/61”, “12/13/62”]
df = DataFrame(id=id, bday=bday)
df.bday = Date.(df.bday, “mm/dd/yy”)
5-element Vector{Date}:
0062-08-23
0066-12-26
0062-01-17
0061-12-30
0062-12-13
Probably because 62 is parsed as year 62. You can do this (I skipped the df part)
Date.(bday, "mm/dd/yy") .+ Year(1900)
3 Likes
gjh
April 20, 2022, 3:48pm
3
Thanks, it works but for dates that are > 12/31/1999.
gjh
April 20, 2022, 4:13pm
4
This was useful. Sorry that I did not find it before posting the question.
I have a file with dates formatted like this:
5/7/10 2:11 for the date 2010-5-7 and the time 2:11 am.
I’m having the hardest time getting that read in properly.
I’m trying something like CSV.read("Data.csv", dateformat=dateformat"m/d/yy H:M"), but my dates are all formatted like this: 0010-5-7.
I have two questions about this:
a) What happened to the yy formatting in Julia 1.0? Am I mis-remembering this from Python?
b) How can I read this data in with the right dates?
Many thanks for any …
julia, dates.jl
Were there no long lasting lessons learned from dealing with this issue so much 20+ years ago?
1 Like