4

I have a form that is due on the first Tuesday of each month. I would like to find a way to automatically populate the due date based on the current date, by showing the date of the next upcoming first Tuesday.

Any ideas?

1

Here is the specific calculation to do this in Cognito Forms:

=DateTime.Today.AddDays(1 - DateTime.Today.Day).AddMonths(1).AddDays("TueMonSunSatFriThuWed".IndexOf((DateTime.Today.AddDays(1 - DateTime.Today.Day).AddMonths(1).DayOfWeek + "").Substring(0, 3))/3)

This calculation leverages DateTime.DayOfWeek to determine the day of the week, converts this to an offset by looking up the day of the week in this text value TueMonSunSatFriThuWed, and adds the corresponding days to the first day of the month.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.