function readOnly(count){ }
Don't have an account?
Search for an answer or ask a question of the zone or Customer Support.
You need to sign in to do that
Sign in to start searching questions
Signup for a Developer Edition
Sign in to start a discussion
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 }
Date today=System.today(); Date todaydate = System.today();Date todaydateinstance = date.newinstance(todaydate.year(), todaydate.month(), todaydate.day());Integer currentyear = todaydate.year();Date startDate = date.newinstance(currentyear, 01, 01);integer numberDaysDue = startDate.daysBetween(todaydateinstance);Integer numberOfWeek = math.MOD(Integer.valueof(math.FLOOR( ( numberDaysDue )/7)),52)+1;
But, it's not.
Check out: http://webexhibits.org/calendars/week.html#SECTION00660000000000000000
for all the gory details. Could it be done in a formula, perhaps, but it ain't pretty! :-)
Fun, fun, fun, Steve Bower.
Thanks for your interest.
john
Code:
Does anyone know how i use the code posted on here to calculate the week number. Im new to Sforce and not even sure what type of code it is??
Many thanks
Dean
Date today=System.today();
Date todaydate = System.today();
Date todaydateinstance = date.newinstance(todaydate.year(), todaydate.month(), todaydate.day());
Integer currentyear = todaydate.year();
Date startDate = date.newinstance(currentyear, 01, 01);
integer numberDaysDue = startDate.daysBetween(todaydateinstance);
Integer numberOfWeek = math.MOD(Integer.valueof(math.FLOOR( ( numberDaysDue )/7)),52)+1;