NexJ Logo

DayOfWeek()

Extracts the day of the week from the specified date. This function takes a date and string value as arguments and returns an integer value. The day of the week is given as value between 1 and 7, where Sunday is 1 and Saturday is 7.

Syntax

DayOfWeek(<date>, <time_zone>)

Input

date

date

The date to get the day of the week from.

time_zone

string

(Optional) The time zone code. This argument specifies the time zone of the date. For example, if you want the date to be in Eastern Standard Time (EST), enter the time zone argument "EST". If you do not specify a time zone, the local time zone of the user who is completing the form is used.

Output

integer

Examples

Assume that you have a form in which there is a date field question with the reference name date_of_birth. In the field, the user chooses January 31, 2000. The user is in the EST time zone.

  • The expression DayOfWeek($date_of_birth) returns 2, because January 31, 2000 is a Monday.
  • The expression DayOfWeek($date_of_birth, "PST") returns 1, because in this example the time zone argument changes the specified date to Pacific Standard Time, which is Sunday, January 30, 2000.

Time zones