Saturday, August 21, 2010

Getting the actual day of the week from a date field

It's the simple things that I sometimes get stuck on. For the longest time, I couldn't figure out how to garner the actual day of the week from a date field value.

Now I share how ridiculously simple it is using Jscript.

var date = crmForm.all.pai_dateworked.DataValue;
var pai_name
var weekday=new Array(7);
weekday[0]="Sunday";
weekday[1]="Monday";
weekday[2]="Tuesday";
weekday[3]="Wednesday";
weekday[4]="Thursday";
weekday[5]="Friday";
weekday[6]="Saturday";
pai_name = weekday[date.getDay()];
crmForm.all.pai_name.DataValue = pai_name;

No comments:

Post a Comment