hello,
I need to calculate what week of the year a particular date falls in, I am unsure on how to do this. After searching the forums I found the following but it seems only to resolve the current date and time. How would I apply the following code or do I do something different??
var vCalendar = java.util.Calendar.getInstance();
var vWeek = vCalendar.get(java.util.Calendar.WEEK_OF_YEAR);
I needed the same recently and created the following method:
var date = arguments[0];
var firstYearDay = new Date(date.getFullYear(), 0);
var day = Math.ceil((date - firstYearDay) / 86400000) + 1;
var firstDay = firstYearDay.getDay();
var days = firstDay + day - 2;
var week = days/7 + 1;
week = Math.floor(week)
return week;
You can also use our dateUtils-Plugin. That allows you to do all kinds of date related stuff easily. While it is finished, it lacks documentation so we did not officially announce that yet. If you are interested, drop me a line. It’s free…