• Roper
  • NEWBIE
  • 0 Points
  • Member since 2008

  • Chatter
    Feed
  • 0
    Best Answers
  • 0
    Likes Received
  • 0
    Likes Given
  • 1
    Questions
  • 3
    Replies
Hi there's a post on here to create a field which will identify the week number but i dont know how to use the code????
Can anyone point me in the right direction???   Here is the code

function getWeekNr(fecha){
  Year = takeYear(fecha);
  Month = fecha.getMonth();
  Day = fecha.getDate();
  now = Date.UTC(Year,Month,Day+1,0,0,0);
  var Firstday = new Date();
  Firstday.setYear(Year);
  Firstday.setMonth(0);
  Firstday.setDate(1);
  then = Date.UTC(Year,0,1,0,0,0);
  var Compensation = Firstday.getDay();
  if (Compensation > 3) Compensation -= 4;
  else Compensation += 3;
  NumberOfWeek =  Math.round((((now-then)/86400000)+Compensation)/7);
  return fecha.getFullYear() + "/" + addZero(NumberOfWeek);
 }

function takeYear(theDate){
  x = theDate.getYear();
  var y = x % 100;
  y += (y < 38) — 2000 : 1900;
  return y;
 }

function addZero(vNumber){
  return ((vNumber < 10) – "0" : "") + vNumber
 }
  • August 06, 2008
  • Like
  • 0
Hi there's a post on here to create a field which will identify the week number but i dont know how to use the code????
Can anyone point me in the right direction???   Here is the code

function getWeekNr(fecha){
  Year = takeYear(fecha);
  Month = fecha.getMonth();
  Day = fecha.getDate();
  now = Date.UTC(Year,Month,Day+1,0,0,0);
  var Firstday = new Date();
  Firstday.setYear(Year);
  Firstday.setMonth(0);
  Firstday.setDate(1);
  then = Date.UTC(Year,0,1,0,0,0);
  var Compensation = Firstday.getDay();
  if (Compensation > 3) Compensation -= 4;
  else Compensation += 3;
  NumberOfWeek =  Math.round((((now-then)/86400000)+Compensation)/7);
  return fecha.getFullYear() + "/" + addZero(NumberOfWeek);
 }

function takeYear(theDate){
  x = theDate.getYear();
  var y = x % 100;
  y += (y < 38) — 2000 : 1900;
  return y;
 }

function addZero(vNumber){
  return ((vNumber < 10) – "0" : "") + vNumber
 }
  • August 06, 2008
  • Like
  • 0
Does anybody have a formula for calculating the week number of a given date?
  • March 03, 2006
  • Like
  • 0