String to Date

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

Thanks, it works but for dates that are > 12/31/1999.

This was useful. Sorry that I did not find it before posting the question.

Were there no long lasting lessons learned from dealing with this issue so much 20+ years ago?