Cognito Forms – Calculate Current Week Number

cognito-formsformulas

I am trying to create a field within a form that will automatically calculate the current week number. It's only for internal use, I just need it to show up on the Entries listing after the form has been submitted.

Back with an add on to my original question… I have been using the formula provided on a few forms and it works Ok other than that the day of the week that the week number changes in the form is not Sunday as expected but on Tuesday…? However my main concern to wanting to be able to use the formula with the exception of using a provided date (ie, the Entry Submission Date) as currently the formula must be a part of the form before an entry is processed in order to apply the correct week number to that specific entry.

Any continued help would be much appreciated! Thank you

Best Answer

Here is the calculation to use.

=Math.Ceiling(DateTime.Today.DayOfYear/7)

I would recommend setting this as the default value of a number field so that it can be changed if necessary.

According to ISO-8601 standard, a week starts on Monday and the first week of the year is the first week containing at least 4 days. There are, in fact many more standards to define weeks and week numbers. While achieving this kind of check using the Cognito calculations would be rather difficult, it probably is unnecessary for most purposes and what is given above should help.