2

Hi I want to convert a 2 digit year date in string format to an Date object. But I an not sure what to use as the format

For 4 digit Dates it works fine, i.e

using Dates 

t1 = "01/01/2017"
Date(t1, "dd/mm/yyyy")

# Out > 2017-01-01

But for 2 digit year

t2 = "27/01/17
Date(t2, "dd/mm/yy")

# Out > 0017-01-27

Any idea what to use as the formatting?

1 Answer 1

3

This seems not be implemented (yet). See the discussion here or the (open) pull request to implement it here.

It is a debated topic, as the default in other languages is to assign years >68 to the twenty century and those <=68 to the twenty-first century, that is a bit subjective, so the Julia developers preferred to go for the explicit way that the missing digits must be explicitly added.

So for now just add 2000 years:

t2 = "27/01/17"
Date(t2, "dd/mm/yy") + Dates.Year(2000)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.