Return to Snippet

Revision: 7506
at July 29, 2008 10:54 by jamesming


Updated Code
function getDateRangeOfWeek(weekNo){
		var d1 = new Date();
		numOfdaysPastSinceLastMonday = eval(d1.getDay()- 1);
		d1.setDate(d1.getDate() - numOfdaysPastSinceLastMonday);
		var weekNoToday = d1.getWeek();
		var weeksInTheFuture = eval( weekNo - weekNoToday );
		d1.setDate(d1.getDate() + eval( 7 * weeksInTheFuture ));
		var rangeIsFrom =  eval(d1.getMonth()+1)   +"/"  +  d1.getDate()  + "/"  +   d1.getFullYear();
		d1.setDate(d1.getDate() + 6);		
		var rangeIsTo = eval(d1.getMonth()+1)   +"/"  +  d1.getDate()  + "/"  +   d1.getFullYear() ;
		return rangeIsFrom + " to "+rangeIsTo;
};

Revision: 7505
at July 27, 2008 20:07 by jamesming


Initial Code
function getDateRangeOfWeek(weekNo){
		var d1 = new Date();
		var numOfdaysPastSinceLastMonday = eval(7 - eval( d1.getDay() + 1 ));
		d1.setDate(d1.getDate() - numOfdaysPastSinceLastMonday);
		var weekNoToday = d1.getWeek();
		var weeksInTheFuture = eval( weekNo - weekNoToday );
		d1.setDate(d1.getDate() + eval( 7 * weeksInTheFuture ));
		var rangeIsFrom =  eval(d1.getMonth()+1)   +"/"  +  d1.getDate()  + "/"  +   d1.getFullYear();
		d1.setDate(d1.getDate() + 6);		
		var rangeIsTo = eval(d1.getMonth()+1)   +"/"  +  d1.getDate()  + "/"  +   d1.getFullYear() ;
		return rangeIsFrom + " to "+rangeIsTo;
};

Initial URL

                                

Initial Description

                                

Initial Title
get date range from week number in year

Initial Tags
date

Initial Language
JavaScript