3
$\begingroup$

More of a 'why' than a 'how' question...

DateValue[{2014,4,12},"DayName"]

returns Saturday, a symbol rather than the string "Saturday".

Every other result that DateValue returns that is not a number is a string not a symbol so why the special case for Days of the Week?

Just to add to the confusion DayNameShort and DayNameInitial do return strings.

$\endgroup$
3
$\begingroup$

As shown inthe documentation, the third parameter of DateValue provides control of the form of the value returned. If you want a String specify that.

DateValue[{2014, 4, 12}, "DayName", String]

"Saturday"

Head[%]

String

|improve this answer|||||
$\endgroup$
  • $\begingroup$ Hmm, despite staring at the docs for a long time I seem to have deliberately ignored that one. Many thanks as that solves a different problem as well. $\endgroup$ – Ymareth Mar 31 '15 at 10:13
  • $\begingroup$ +1. Somewhat related. Any reason that the day names are available as Symbols as well as Strings, but the month names only as Strings? $\endgroup$ – Romke Bontekoe Mar 17 '19 at 8:31
  • $\begingroup$ @RomkeBontekoe - I don't know why Wolfram (company) decided to build in definitions for days as symbols but not months. DateValue is then consistent with that decision. $\endgroup$ – Bob Hanlon Mar 17 '19 at 12:31

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

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