I am working with a proprietary blend of Javascript and have no idea what I am doing.
What I am attempting to do is to take the value from a field (paydate) and convert it to a numerical form.
Next, I need to take a different value - from another field (ach adjust) - and add it to the original value to produce a new value (paydate + ach adjust)
The resulting numerical value needs to be converted to the corresponding day of the week.
Since the days can result in a large enough time frame, instead of the GetDay function, I used the GetDate function. Here is what I have:
var pd = paydate.getDate();
// coverts the value from the field "paydate" to a numerical value within
// the pd variable.
var adj = clientMASTER_assoc_adjachdays;
// converts the value from the field "clientMASTER_assoc_adjachdays" to
// a variable. This value is already in a numerical form.
var comp = (pd+adj);
// converts the value resulting from the addition of the values within the
// two variables, pd and adj, to the variable comp.
comp;
// outputs the variable.
This script would work perfectly if I just wanted a numerical value (from 1 to 31), but I need the actual day of the week (Sun..Mon...Tue...Wed...Thur...Fri...Sat). How can I accomplish this?
Bear in mind (in case I did not already mention it) that this is a proprietary blend of Javascript. In the situation that we previously discussed, I finished with the following code:
var pd = paydate.getDay();
// converts the value from the "paydate" field to an integer.
var adj = clientMASTER_assoc_adjachdays;
// converts the integer from the "clientMASTER_assoc_adjachdays" field to a variable.
var comp = (pd+adj);
// adds the two variables, pd and adj together, and converts the result to a variable.
comp = comp%6;
// constrains the results of the previous mathematical equation to a value of // less than or equal to 6.
var arDays = new Array("Sunday", "Monday", "Tuesday",
"Wednesday", "Thursday", "Friday", "Saturday");
// opens an array of the days of the week (0=Sunday,1=Monday...)
var achd = arDays[comp];
//compares the results of the comp variable to the arDays array and converts the result to another variable; the day of the week.
Well, the array does consist of only the numbers 1 - 6 (0=Sunday, 1=Monday, 2=Tuesday, 3=Wednesday, 4=Thursday, 5=Friday, 6=Saturday). Could you please explain why you need a 7 for all of us poor, uneducated people?
Take any day of the month and note the day of the week. Now add or subtract 7, 14, 21, or 28. Won't it be the same day of the week?
Take any positive integer and divide it by seven. If you ignore the quotient and pay attention only to the remainder, how big can it get and how small can it get? If you chose 13, the remainder would be 6. Add 1 to it, 14 is evenly divisible by 7 so the remainder will be zero.
Bookmarks