Skip to content

Get an activity at a specific date

In this slightly more complex example, it will be demonstrated how to get an activity occurring at a specific date.

The following logical steps are performed:

  • Set the desired date using the datetime and the ZoneInfo modules.
  • List all activities while paying attention that the date parameter is set to a date before the desired date.
from datetime import datetime
from zoneinfo import ZoneInfo

from pyholdsport import Holdsport, HoldsportActivity

timezone = ZoneInfo("Europe/Copenhagen")

holdsport = Holdsport(
    holdsport_username="username",
    holdsport_password="password",
)
team_id = 123
activity_date = datetime(2026, 3, 13, tzinfo=timezone).date()

activities: list[HoldsportActivity] = holdsport.get_activities(
    team_id=team_id,
    date="2026-03-10",  # (1)!
)
for activity in activities:
    start_time = datetime.strptime(activity.starttime, "%Y-%m-%dT%H:%M:%S%z")
    if start_time.date() == activity_date:
        print(f"Found activity: '{activity.name}'")
        print(f"Activity id: {activity.id}")
        print(f"Activity start time: {activity.starttime}")
        break
  1. This date should be before the desired date, as the API returns activities starting from the given date.