8

Want to filter list items that were modified on last week

Think pseudocode for this will be Modified >= ( [Today]-WEEKDAY-7 ) && Modified <= ( [Today]-WEEKDAY )

No matter what day of week is today, we need items from previous week:

enter image description here

So as I understand I need to create calculated fields

Previous_Week_StartDate: =[Today]-WEEKDAY-7

and

Previous_Week_EndDate: =[Today]-WEEKDAY

and then filter view like

Modified >= Previous_Week_StartDate and Modified <= Previous_Week_EndDate

But when I use something like '=WEEKDAY([Today])' in calculated column I get errors. Somebody did something like this?

upd.: I can also create View programmatically (with custom CAML query), but don't know how to construct such query

upd.2: Resolved. It was easier: created two calculated fields(return type as Date):

StartWeek, formula:

=Modified-(WEEKDAY(Modified)-1)

EndWeek:

=StartWeek+7

and created filter in views:

enter image description here

So I compare intervals from Sunday to Sunday (think it depends on Your Regional settings)

1 Answer 1

5

Yes it's normal, You should be aware of the [Today] and [ME] can't be used in the Calculated Field, Please check all details and alternative solution at

How to use Today and Me in Calculated column

Meanwhile, In your view, you can use filter directly to filter the files modified within the last 7 days as

enter image description here

4
  • Thank You for provided link! Uff.. I thought it is much easier with calculated columns.. Already used [Today]-7, but need only previous week.. Will try to use caml and create this view programmatically
    – Gennady G
    Commented May 11, 2017 at 14:16
  • you are welcome @GennadyG , in my opinion, the easier method depnd on your requirment , meanwhile the OOTB filter option may be help, so Could you please try to filter modified is greater than [Today]-7 and and less than [Today]. I am sorry if I am confused to understand your mean so please inform me what is the difference between last 7 days and last week ! Commented May 11, 2017 at 14:25
  • Oh, my english not native so I confused You. I mean 'previous week', so if today we have May 11, we need results between 1 May - 7 May. If tomorrow we have 12 May, we still need results between 1 May and 7 May (because it was previous week)
    – Gennady G
    Commented May 11, 2017 at 14:38
  • Okay, Now it's clear let's search together for the best solution to achieve that :) Commented May 11, 2017 at 14:44

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.