In Mathematica 13.3, I've a number, say 20231114, and I want to convert it to a Wolfram Language (WL) DateObject. My first attempt failed:

FromDateString[ToString[20231114], {"Year", "Month", "Day" }]

This fails with Mathematica complaining that enter image description here

As "Year", "Month" and "Day" refer to length delimited parts, I expected this to work even without explicitly specifying separators, i.e. leaving them out.

BTW: The "Delimiter" option is broken in Mathematica/WL 13.3.

My question is: Is there a way to use FromDateString to convert such a date string formatted as "CCYYMMDD"?

And, in general a date time string formatted as "CCYYMMDDHHmmSS" etc?


1 Answer 1

FromDateString[ToString[20231114], DateFormat -> "ISODate"]


  <|"Elements" -> {"Year", "Month", "Day", "Hour", "Minute", "Second"}, 
                   "Delimiters" -> {""}

do work.

  • $\begingroup$ Also FromDateString[ToString[20231114]<>"haha",{"Year","Month","Day","haha"}] $\endgroup$ Commented Dec 17, 2023 at 15:54

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.