Click to See Complete Forum and Search --> : Calculations


tsp1lrk
01-21-2004, 07:49 AM
Hello,

I'm trying to figure out code for a calculation I'm working with- I need to determine a date and a year from the following information: (uses the 2nd number)

237= 2(2002); 37 - 13 = Week 24 of 2002 = June 2002

Another one:
212= 2(2002); 12 - 13 = Week 51 of 2001 = December 2001

Using a different number:
437 = 4(2004); 37 – 13 = Week 24 of 2004 = June 2004

These numbers are random, but are always 3 digits, the first one indicates the year- the second 2 need to be subtracted from 13. HELP!

I'm using ASP.net/VB.net but could use a Javscript I'm sure; I have 2 textboxes (Or I guess I could use one as well) to collect the info. I'm stuck trying to determine how to begin- Can anyone help me? Appreciate any insight on this one-

Thanks,
Lisa

leeb
01-21-2004, 09:52 AM
try this:

437/100 = 4.37

then take the remainder. If that is 0.37 then use:

0.37*100 = 37

TheBearMay
01-21-2004, 10:14 AM
Here's another idea that may work for you...


function dateDecoder(dCode){
var dcYear="200"+dCode.substring(0,1);
var dcWeek=dCode.substring(1,3)-13;
if (dcWeek <=0){
dcWeek+=52;
dcYear-=1;
}
var dcDays=7*(dcWeek-1);
var dcMillSec=(((dcYear-1970)*365.25)+dcDays)*24*60*60*1000;
return new Date(dcMillSec);
}
...
<input type="text" id="codedDate" onchange="alert(dateDecoder(this.value));">
...

tsp1lrk
01-21-2004, 10:56 AM
Hey! Thank You- Is there anyway to show what week that is, I'm ultimately looking for this:

Week XX of Year XX

The other information is good too, This is very helpful, I just need to show the weeks in there as well!

Much appreciated-:D

TheBearMay
01-21-2004, 11:16 AM
You may want to check and see if dcWeek and dcYear contain what you want.