cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Submit your abstract to the call for content for Discovery Summit Americas by April 23. Selected abstracts will be presented at Discovery Summit, Oct. 21- 24.
Discovery is online this week, April 16 and 18. Join us for these exciting interactive sessions.
robot
Level VI

Convert Work Week into Date (JMP10)

Hi,

I have a data set that lists work week, and I am trying to convert this number into a calendar date.  I know JMP has a function to convert calendar date into work week, but I would like to do the opposite.

For example, I have a number like 201334, representing YYYYWW.  How can I convert this back into a date?  My reason is that I would like to be able to plot this data on a time trend, but without large gaps between years (for example from 201252 to 201301).

I am sure I can do this by calculating the number of seconds from 1/1/1904, but I am starting to get a headache trying to account for leap years, week starting days, and whatnot.  I hope there is an easier way to do this.

Thanks!

1 ACCEPTED SOLUTION

Accepted Solutions

Re: Convert Work Week into Date (JMP10)

I wrote a script for this based on how my previous company defined work weeks.  You can modify it to however you define work weeks where you are.

//Arguments:

//_ww_ = Work week, 1 to 53

//_year_ = Four digit year, e.g. 2004

//_dayofweek_ = 1-7 (1 = Sunday...)

::iwwtodate = Function(

     //Function Arguments

     {_ww_, _year_,_dayofweek_,

     //Local Variables

     _ww01thisyear_ = 0,

     _sundayww01_ = 0

     },

     _ww01thisyear_ = Informat("01Jan" || Char(_year_));

     _sundayww01_ =_ww01thisyear_ - (Day Of Week (_ww01thisyear_)- 1) * 24 * 3600;

     (_ww_ - 1) * 7 * 24 * 3600 +_sundayww01_ + (_dayofweek_ -1) * 24 * 3600

);

Message was edited by: Chadd McNicholas

View solution in original post

2 REPLIES 2

Re: Convert Work Week into Date (JMP10)

I wrote a script for this based on how my previous company defined work weeks.  You can modify it to however you define work weeks where you are.

//Arguments:

//_ww_ = Work week, 1 to 53

//_year_ = Four digit year, e.g. 2004

//_dayofweek_ = 1-7 (1 = Sunday...)

::iwwtodate = Function(

     //Function Arguments

     {_ww_, _year_,_dayofweek_,

     //Local Variables

     _ww01thisyear_ = 0,

     _sundayww01_ = 0

     },

     _ww01thisyear_ = Informat("01Jan" || Char(_year_));

     _sundayww01_ =_ww01thisyear_ - (Day Of Week (_ww01thisyear_)- 1) * 24 * 3600;

     (_ww_ - 1) * 7 * 24 * 3600 +_sundayww01_ + (_dayofweek_ -1) * 24 * 3600

);

Message was edited by: Chadd McNicholas

robot
Level VI

Re: Convert Work Week into Date (JMP10)

Very handy!  Thank you for sharing.