Create a function to sort and return bye date

In ss4, i defined a start_date variable in kind of pages, and we need a function that return and sort Only between now and 14 days after start_date, in the other words i need the pages only between:
Start_date < selected page < Start_date + 14
End_date < selected page < End_date - 14
(2 weeks after start and two weeks before end)

You can use the SilverStripe search filter modifiers for this:

So you would calculate the start and end of the period and then have something like:

$pages = YourPageClass::get()->filter([
  'PageDate:GreaterThanOrEqual' => $startTime,
  'PageDate:LessThanOrEqual' => $endTime
1 Like

I think that i need to explain more for the function that i need, I creat a TheartePage that contain:

private static $db = [
        'StartDate' => 'Date',
        'FinishDate' => 'Date',

and i want to loop in a page (FirstWeek) for two weeks from StartDate & a page to loop to weeks untill FinishDate (LastWeek) (According to today {$Now})
(e.g. StartDate=2018,11,01 & FinishDate=2019,03,15)
(if the today=2018,11,05{$Now} loop the in FirstWeek & if today{$Now}=2019,03,12 shown in LastWeek)