The Phillies have lost six of their last seven games and will finish a 60-game season with a losing record. Yet they enter the final day of the season still with a shot to make the postseason.

The Phillies will secure the final spot in the National League playoffs if they win on Sunday, and the Brewers and Giants both lose. If that happens, all three teams will finish the season with 29-31 records. The tiebreaker is divisional record, which would go to the Phillies.

The Phillies, if everything goes their way on Sunday, will open the postseason on Wednesday in Los Angeles against the Dodgers as the No. 8 seed. The Phillies would be the first team with a losing record in major-league history to reach the playoffs, not counting the 1981 split-season playoff teams.

Here is the setup:

Phillies (28-31) at Rays (39-20), 3:10 p.m.

Aaron Nola starts for the Phillies, who dropped the first two games of the series. Zach Eflin and Spencer Howard should both be available in the bullpen if manager Joe Girardi needs a late arm. The Rays clinched the top seed in the American League playoffs with Saturday night’s win, so they will have little to play for on Sunday.

Brewers (29-30) at Cardinals (29-28), 3:15 p.m.

Brett Anderson starts for the Brewers against Austin Gomber as both teams are vying for postseason spots. Both clinch a berth with a win. By Sunday, the Cardinals will have played just 58 games. They could be forced to play a doubleheader on Monday in Detroit if it determines another team’s postseason fate. But the Phillies can no longer catch St. Louis.

Padres (35-23) at Giants (29-30), 3:05 p.m.

Drew Smyly, who made 12 starts last season for Gabe Kapler with the Phillies, will start for the Giants. The Giants have lost three straight to the Padres, who have nothing to play for. They started most of their regulars on Saturday night, so they might look to give Manny Machado and Fernando Tatis Jr. a rest before the playoffs begin.