Dayofweek function will not produce a number

I can’t get the dayofweek function to produce a number. The documentation says it is a numeric reult but I cannot get there.

I just tried:

message dayofweek(today())

It produced 6 for Saturday as expected.

It’s parameter needs to be a date, like the today() function that Gary used, or something like this.

The parameter of the dayofweek( function can be can also be a date field.

Or the output of a monthmath( function, or monthfirst( function etc. It can be anything with a datatype of date.

So formulafill val(datepattern(«DATE NO.»,“dayofweek”)) , where «DATE NO.» might be 2,448,476, should work but it doesn’t. Pan X Help says it will work. Also Pan X help defines day of week s a number.

Please give us some context. “It doesn’t work” is a meaningless phrase, if we don’t know what you are trying to accomplish.

The dayofweek( function returns a number. “dayofweek” as a parameter in the datepattern( function will return the name of that day.

image

Context is that when I fill a field with it the result is always 0 or blank depending upon the field type.

The problem is that you are confusing the dayofweek( function with the datepattern( function. The dayofweek( function returns a number, just like the Help file says it does. The datepattern( function returns text. Among the possible date patterns are “dayofweek” or “DayOfWeek” or “DAYOFWEEK” depending on whether you want all lower case, first letter upper case, or all upper case.

BINGO! Thank you very much Dave.

and (val(datepattern(anything

is guaranteed to produce an unpredictable result…

Actually, you can predict that val(datepattern(today(),"dow") will produce the same result as dayofweek(today()).

The “dow” date pattern is missing from the documentation. I submitted a correction last month.

1 Like

Thank you Dave. I believe I intaked that change a couple of weeks ago, so it will appear in b27. It’s already in the web version of the documentation.

1 Like