MathGroup Archive 2012

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

Search the Archive

Re: Question about DayOfWeek

  • To: mathgroup at
  • Subject: [mg126201] Re: Question about DayOfWeek
  • From: Murray Eisenberg <murray at>
  • Date: Wed, 25 Apr 2012 00:31:44 -0400 (EDT)
  • Delivered-to:
  • References: <>
  • Reply-to: murray at


   Wednesday == Wednesday

is comparing two _identical_ symbolic expressions, hence gives True. But

  Wednesday == Thursday

is comparing two non-identical objects with head Symbol, hence cannot 
determine that they are equal and so returns the input expression 

That's just like evaluating, say,

   a == b

where a and b are just symbols with no value assigned to them; you 
obtain the input as result.

Did you read the documentation?

The page ref/Equal (==) says this function returns False when the two 
objects "are determined to be unequal by comparisons between numbers or 
other raw data, such as strings." But Wednesday and Thursday are 
evidently not such data.

Compare that with the documentation ref/SameQ (===). Thus:

   Wednesday === Wednesday

   Wednesday === Thursday

That's the function you need to use for your evidently intended purpose.

On 4/24/12 5:34 AM, Kent Holing 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?

Murray Eisenberg                     murray at
Mathematics & Statistics Dept.
Lederle Graduate Research Tower      phone 413 549-1020 (H)
University of Massachusetts                413 545-2859 (W)
710 North Pleasant Street            fax   413 545-1801
Amherst, MA 01003-9305

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