Re: Question about DayOfWeek

*To*: mathgroup at smc.vnet.net*Subject*: [mg126201] Re: Question about DayOfWeek*From*: Murray Eisenberg <murray at math.umass.edu>*Date*: Wed, 25 Apr 2012 00:31:44 -0400 (EDT)*Delivered-to*: l-mathgroup@mail-archive0.wolfram.com*References*: <201204240934.FAA24505@smc.vnet.net>*Reply-to*: murray at math.umass.edu

Because 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 unevaluated. 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 True Wednesday === Thursday False 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 math.umass.edu 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

**References**:**Question about DayOfWeek***From:*Kent Holing <KHO@statoil.com>