{"record":{"id":"5fb31ec0e0acb736","repo":"yt-dlp/yt-dlp","slug":"date-range-self-the-start-date-must-be-befo","errorCode":null,"errorMessage":"Date range: \"{self}\" , the start date must be before the end date","messagePattern":"Date range: \"(.+?)\" , the start date must be before the end date","errorType":"validation","errorClass":"ValueError","httpStatus":null,"severity":"error","filePath":"yt_dlp/utils/_utils.py","lineNumber":1434,"sourceCode":"    else:\n        return date_str\n\n\nclass DateRange:\n    \"\"\"Represents a time interval between two dates\"\"\"\n\n    def __init__(self, start=None, end=None):\n        \"\"\"start and end must be strings in the format accepted by date\"\"\"\n        if start is not None:\n            self.start = date_from_str(start, strict=True)\n        else:\n            self.start = dt.datetime.min.date()\n        if end is not None:\n            self.end = date_from_str(end, strict=True)\n        else:\n            self.end = dt.datetime.max.date()\n        if self.start > self.end:\n            raise ValueError(f'Date range: \"{self}\" , the start date must be before the end date')\n\n    @classmethod\n    def day(cls, day):\n        \"\"\"Returns a range that only contains the given day\"\"\"\n        return cls(day, day)\n\n    def __contains__(self, date):\n        \"\"\"Check if the date is in the range\"\"\"\n        if not isinstance(date, dt.date):\n            date = date_from_str(date)\n        return self.start <= date <= self.end\n\n    def __repr__(self):\n        return f'{__name__}.{type(self).__name__}({self.start.isoformat()!r}, {self.end.isoformat()!r})'\n\n    def __str__(self):\n        return f'{self.start} to {self.end}'\n","sourceCodeStart":1416,"sourceCodeEnd":1452,"githubUrl":"https://github.com/yt-dlp/yt-dlp/blob/81ecd58b1394793e6da9998cc19fdb45657f1685/yt_dlp/utils/_utils.py#L1416-L1452","documentation":"Error \"Date range: \"{self}\" , the start date must be before the end date\" thrown in yt-dlp/yt-dlp.","triggerScenarios":"Thrown at yt_dlp/utils/_utils.py:1434 when the library encounters an invalid state.","commonSituations":"See trigger scenarios.","solutions":["Swap the start and end dates so the start is earlier than the end, e.g. --dateafter 20240101 --datebefore 20240201.","Check relative date expressions ('today', 'now-3days') that may evaluate in an unexpected order."],"exampleFix":"Validate range ordering on construction: if self.start > self.end: raise ValueError(f'Date range: \"{self}\" , the start date must be before the end date')","handlingStrategy":null,"validationCode":null,"typeGuard":null,"tryCatchPattern":null,"preventionTips":[],"tags":[],"backgroundTag":null,"analyzedSha":"81ecd58b1394793e6da9998cc19fdb45657f1685","analyzedAt":"2026-08-22T12:21:25.439Z","schemaVersion":2},"datasetVersion":"2026-08-22T14:17:55.899Z"}