MathGroup Archive 2012

[Date Index] [Thread Index] [Author Index]

Search the Archive

Re: Question about DayOfWeek


Needs["Calendar`"]

Equal can only compare "between numbers or other raw data, such as
strings." If symbols are involved the expression will be interpreted
by Mathematica as an equation.

Head /@ {Wednesday, Thursday}

{Symbol, Symbol}

You need to use SameQ ( === ) to test whether symbols are literally
the same symbol.

Wednesday === Thursday

False

DayOfWeek[{1975, 1, 1}] === Wednesday

True

DayOfWeek[{1975, 1, 1}] === Thursday

False

Alternatively,

ToString[Wednesday] == ToString[Thursday]

False

ToString /@ (DayOfWeek[{1975, 1, 1}] == Thursday)

False


Bob Hanlon


On Tue, Apr 24, 2012 at 5:34 AM, Kent Holing <KHO at statoil.com> wrote:
> DayOfWeek[{1975,1,1}]==Wednesday gives True (as it should), but DayOfWeek[{1975,1,1}]==Thursday gives
> Wednesday == Thursday and not False, as it should? Why is it so?
>



  • Prev by Date: Re: Question about DayOfWeek
  • Next by Date: from a 2d-figure to an interactive 3d model? is it possible with mathematica?
  • Previous by thread: Re: Question about DayOfWeek
  • Next by thread: Re: Question about DayOfWeek