Based on recent requests i want to post this solution for getting the n’th given day of any month in any year.
For example the third Friday of current month:
3 thoughts on “Get n’th given day of any month”
Great job again. I did find that the returned value is more than the date. It returns
Day Mon date h:mm:ss EST YYYY
for me to use this is sharepoint I have to format the date to m/d/yyyy. I tried to format the myDay var but it did not work, so at the end of the function before return date; I added this line
This returns a date format that SP can use in it’s date field. Great job on both scripts.
so now that I believe the output is formatted correctly m/d/yyyy, I cant seem to do much with the output. I need to get saturdays date also. Not always is the 3 friday going to proceed the 3 saturday. I thought adding one day to myDay would slove for this, but it is not.
I tried this:
var myDay2 = myDay.setDate(myDay.getDate() + 1);
Did I miss something in the date format, so the output is recognized as a date, or am I doing something wrong here adding a day to the output?