Manipulation and sorting of date strings, location Australia
Use the the syntax where you specify the order:
DateObject[{"06.02.97",{"Day","Month","YearShort"}}]
DateObject[{1997, 2, 6, 0, 0, 0.}, "Instant", "Gregorian", -7.]
Since I couldn't find the elegant solution @Carl Woll did, how about this?
Quiet@DateObject@StringReplace[
"06.02.97",
day__ ~~ "." ~~ mon__ ~~ "." ~~ yr__ :> mon <> "." <> day <> "." <> yr
]
DateObject[{1997, 2, 6}]
It does throw the warning
DateObject::ambig: "Warning: the interpretation of the string 02.06.97 as a date is ambiguous."
but since you know this is what you want, then you can use the Quiet
.
As for your second question, in general you could do
DateObject /@ listofdatestrings
but if all of the date strings are in the day.month.year
format as above, then you could use
DateObject /@ StringReplace[
listofdatestrings,
day__ ~~ "." ~~ mon__ ~~ "." ~~ yr__ :> mon <> "." <> day <> "." <> yr
] // Quiet
For example
DateObject /@ StringReplace[
{"06.02.97", "30.08.90"},
day__ ~~ "." ~~ mon__ ~~ "." ~~ yr__ :> mon <> "." <> day <> "." <> yr
] // Quiet
{DateObject[{1997, 2, 6}], DateObject[{1990, 8, 30}]}