Skip to main content
cancel
Showing results for 
Search instead for 
Did you mean: 
ljackson
Creator
Creator

Create a date range within a button

I need to select a date range (on a button) that does not include the current week.   I've searched the archives and found SO many date range related questions, but nothing that answers my query.

I want to select the last 4 weeks, previous to the current week.  This week is week 41, so I need the button to select weeks 37 to 40.

I've set the button actions as below, and it very happily selects from week 37 onwards, but I can't work out how to exclude the current week [max(WeekNo()].

Can anyone help?

Thank you.

Date Range.jpg

1 Solution

Accepted Solutions
ljackson
Creator
Creator
Author

I worked it out - thank you David for helping me find the last piece in the puzzle

I set up a variable, then selected the variable for the Field.   This then selected weeks 37 to 40.   I think this is the long winded way of doing it, but I get the result I need so I'm happy! 

Thanks again

Set Variable.jpg

Select Variable.jpg

View solution in original post

7 Replies
DavidFoster1
Specialist
Specialist

try

=('>=' & Week(today()-35) & ' and ' & '< ' & Week(today()-7)

ljackson
Creator
Creator
Author

Thank you David.

I tweaked your expression to this:

=('>=' & Week(today()-28) & ' and ' & '<' & Week(today()))

In the selection box it now shows this:

Selection Box.jpg

but ........it's selecting all weeks less than 41, so has selected weeks 1 to 40.   It seems the second part of the expression is over-riding the first part.

ljackson
Creator
Creator
Author

I switched it around to this:

=('<' & Week(today()) & ' and ' & '>=' & Week(today()-28))

But now it's ignoring the first part of the expression, and includes weeks 37 to 52.

tresesco
MVP
MVP

Could you share your sample app that shows the issue?

ljackson
Creator
Creator
Author

I worked it out - thank you David for helping me find the last piece in the puzzle

I set up a variable, then selected the variable for the Field.   This then selected weeks 37 to 40.   I think this is the long winded way of doing it, but I get the result I need so I'm happy! 

Thanks again

Set Variable.jpg

Select Variable.jpg

ljackson
Creator
Creator
Author

Here's the simple way:

Button.jpg

DavidFoster1
Specialist
Specialist

You are welcome. Could I be cheeky and get you mark my response as the correct/helpful answer. I know! I am a total points junkie 🙂