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$
0

1 Answer 1

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

$\endgroup$
3
  • $\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
    Commented Mar 31, 2015 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$ Commented Mar 17, 2019 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
    Commented Mar 17, 2019 at 12:31

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.