How can I make a date selected to fall on the next saturday of that week?
This means that if a user selects today 24th on a date field, I want Saturday 30th to show in the date field.
How can I script this?
Thanks.
Solved! Go to Solution.
Views
Replies
Total Likes
try this in the exit event of the calendar in formcalc:
var originalDate = Date2Num($.formattedValue, "DD/MM/YY")
var dayOfWeek = Num2Date(originalDate, "E")
var newDate = 7 - dayOfWeek
if (dayOfWeek < 7) then
$ = Num2Date((originalDate + newDate),"DD/MM/YY")
endif
just make sure your pattern for the calendar is DD/MM/YY (or adjust the code to whatever your pattern is).
Views
Replies
Total Likes
try this in the exit event of the calendar in formcalc:
var originalDate = Date2Num($.formattedValue, "DD/MM/YY")
var dayOfWeek = Num2Date(originalDate, "E")
var newDate = 7 - dayOfWeek
if (dayOfWeek < 7) then
$ = Num2Date((originalDate + newDate),"DD/MM/YY")
endif
just make sure your pattern for the calendar is DD/MM/YY (or adjust the code to whatever your pattern is).
Views
Replies
Total Likes
Unfortunately whyisthisme,
your code does not work. the result is '07/01/00' no matter what date is chosen.
Please test again and help
Views
Replies
Total Likes
Sorry,
the script was very helpful. I forgot to change to 'formcalc'
thanks a ton.
Views
Replies
Total Likes
Views
Likes
Replies