11
$\begingroup$

DateList (and other date functions such as DateObject) were very good at catching ambiguous dates. However it looks like they have reverted and now seem to read DD-MMM-YYYY (Date, ShortMonth, Year seperated by "-") as negative years.

$Version

"14.1.0 for Microsoft Windows (64-bit) (July 16, 2024)"

DateList["15-Dec-2023"]

{-2023, 12, 15, 0, 0, 0.}

And in V14

$Version

"14.0.0 for Microsoft Windows (64-bit) (December 13, 2023)"

DateList["15-Dec-2023"]

{2023, 12, 15, 0, 0, 0.}

Edit:

Reported this to Wolfram and they replied

"It does appear that DateList is not properly parsing date strings in this format. An issue report has been forwarded to our developers."

Case 5169744

$\endgroup$
2
  • $\begingroup$ Works with: DateList["15 Dec 2023"]? $\endgroup$ Commented Aug 12 at 8:39
  • $\begingroup$ @MariuszIwaniuk I am not sure, I have uninstalled v14.1. I suspect it should work. $\endgroup$ Commented Aug 13 at 1:47

1 Answer 1

12
$\begingroup$

By the way, in Version 14.1 the whole pipeline for handling dates (and times) has been dramatically speeded up, most notably conversion from strings, as needed in the import of dates. Source

Furthermore, "YearSigned" was added as a possible element in DateString (but not to the autocomplete). Both of these likely contribute to the issue you are seeing.

(* Version 14.0 *)
DateString[{-2022, 2, 31}, "Year"]
(* "-2022" *)

(* Version 14.1 *)
DateString[{-2022, 2, 31}, "Year"]
(* "2022 BC" *)
DateString[{-2022, 2, 31}, "YearSigned"]
(* "-2022" *)

Is it a bug? Hard to decide, it certainly is slightly unexpected. What it could do is return an error message DateList::ambig, hinting that the interpretation is ambiguous.

In any case, I would say that you really shouldn't rely on the automatic interpretation of date strings, especially when you give it in an unconventional format. Just save yourself from issues and manually specify the elements:

DateList[{"15-Dec-2023", {"Day", "-", "MonthNameShort", "-", "Year"}}]
(* {2023, 12, 15, 0, 0, 0.} *)
$\endgroup$
2
  • $\begingroup$ I had a report with lots of ambiguous strings that the date interpreter handled well. I did not know ahead of time what format it would take eg {"Day", "-", "MonthNameShort", "-", "Year"}, or {"Day", "", "Month", "", "YearShort"} etc. I suppose another work around is Abs[DateList[...] $\endgroup$ Commented Aug 13 at 1:51
  • 1
    $\begingroup$ @IntroductionToProbability, it seems that Interpreter["Date"]["15-Dec-2023"] works as expected (although it is significantly slower, of course) ... So you might try using this instead. $\endgroup$
    – Domen
    Commented Aug 13 at 9:00

Your Answer

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

Not the answer you're looking for? Browse other questions tagged or ask your own question.