Date Range from WEEKNUM

I understand that WEEKNUM can pull the week number from a given date, my question is, If I can provide the WEEKNUM, can I generate a date range based off my WEEKNUM? How would I go about this?

Could you please try the below expression? It will give the first date of the week (Sunday per AppSheet day/date functions standards. for Monday as first day, please add 2 in the end of expression instead of 1)

EOWEEK(TODAY())+ ([WEEKNUMBER]-WEEKNUM(TODAY())-1)*7 +1

[WEEKNUMBER] column gives the week number input. By the nature of expression, it will work only for the current year (currently 2021) . The expression will become that much more complex if the week numbers belong to different years.

Please test well.

For getting other days of the week, one may need to construct a list by adding 2, 3, …7 in the end of the expression.

So Saturday ( last day of the week ) date will be

EOWEEK(TODAY())+ ([WEEKNUMBER]-WEEKNUM(TODAY())-1)*7 +7

2 Likes

Thank you kind sir, im trying to decode logically the expression which already blew my mind

I will update you when i put into my app thank you for your effort either way!

2 Likes

It’s saying invalid input type: Unknown :confused: I tried changing he column types making the [weeknum] column as Number

Please post screenshot of your expression , where you are using it and column type ( input column)

1 Like

im starting to wrap my mind around the concept though ima see if i can fool with it a little

What I am going for, is a UI that allows user to ‘scroll’ through weeks, then i would have slices that would display the information for that week. So we work off a point system, and you generate points by doing tasks and working in the office. The points represent a % of profit.

All that aside, im trying to have a counter or somethign so if i +1 the WEEKNUM that it will display the week’s info that im selecting

Maybe i have a table that has the weeks then i can just reference it?

Please try changing the Weeknum column name to WEEKNUMBER or something that is different from [Weeknum]

Weeknum could be a reserved word, since it is used in function WEEKNUM()

1 Like

I tested again and it works for me.

Results

2 Likes

column type weeknumber = Number?

Yes, correct.

1 Like

You are correct sir, God bless

1 Like