Get Week Number from Date
This function displays the week number of the year by current date in a text or read only element. It is mostly used for payroll purposes because it comes out with a number from 1-53 weeks of the year.Simply put this in the page level javascript of the form that will be utilizing this function:
var today = new Date()
Date.prototype.getWeek = function() {
var onejan = new Date(this.getFullYear(),0,1);
return Math.ceil((((this - onejan) / 86400000) + onejan.getDay()+1)/7);
}
This gives you the ability to call the getWeek() method on the today variable that is initialized in the page level java script.
Now all you must do is put today.getWeek() in the dynamic value of a text, number, or read only element and the week number of the year will be displayed.
**If you would like to get the month of a date element earlier on the form you must put date_data_column_name.getWeek() in your dynamic value so that you are referencing the date element on your form.
Comments
0 comments
Please sign in to leave a comment.