Drexel dragonThe Math ForumDonate to the Math Forum



Search All of the Math Forum:

Views expressed in these public forums are not endorsed by Drexel University or The Math Forum.


Math Forum » Discussions » Software » comp.soft-sys.math.mathematica

Topic: IsoWeek Function
Replies: 4   Last Post: Jul 18, 2012 1:37 AM

Advanced Search

Back to Topic List Back to Topic List Jump to Tree View Jump to Tree View   Messages: [ Previous | Next ]
hmichel@cox.net

Posts: 120
Registered: 1/29/05
Re: IsoWeek Function
Posted: Jul 16, 2012 5:01 AM
  Click to see the message monospaced in plain text Plain Text   Click to reply to this topic Reply

See:

http://mathematica.stackexchange.com/questions/4551/determining-the-week-of-
a-year-from-a-given-date

https://groups.google.com/forum/?hl=bn&fromgroups#!topic/comp.soft-sys.math.
mathematica/PbwD8fETs3A

There maybe even easier ways to implement this functionality.

http://en.wikipedia.org/wiki/Calculating_the_day_of_the_week

Hans

-----Original Message-----
From: Murta [mailto:rodrigomurtax@gmail.com]
Sent: Sunday, July 15, 2012 10:44 PM
Subject: IsoWeek Function

Hi All

Please, in Mathematica 9 include IsoWeek functions in the standard into
DateList and DateString. It would be simple if we have a "ISOWeekYear" and
"ISOWeekNumber" as in Oracle and SQL.
Today it's necessary to implemente our own functions, and I get very slow
performance results.
I use that to take ISO Week numbers:

ISOWeek[x_]:=Module[{baseDate,year454,weekNames,numWeek},

weekNames={"Sunday","Monday","Tuesday","Wednesday","Thursday","Friday","Satu
rday"};

year454=First@DateList@DatePlus[x,-Position[weekNames,DateString[DatePlus[x,
-1],{"DayName"}],1][[1,1]]+4];
baseDate={year454,1,3};

numWeek=IntegerPart[1/7(DateDifference[baseDate,x]+Position[weekNames,DateSt
ring[baseDate,{"DayName"}],1][[1,1]]+5)];
{year454,numWeek}
]

Example
ISOWeek["20120101"]
{2011,52}

I tried to compile it, but with no sucess..
Any clue?
Another tip for the developer is create an string "WeekDayNumber", that can
return the week day number. Today we have option just to names.
tks in advance
Murta





Point your RSS reader here for a feed of the latest messages in this topic.

[Privacy Policy] [Terms of Use]

© Drexel University 1994-2014. All Rights Reserved.
The Math Forum is a research and educational enterprise of the Drexel University School of Education.