Stay organized with collectionsSave and categorize content based on your preferences.
Returns a DateRange covering the unit of the specified type that contains this date, e.g., Date('2013-3-15').getRange('year') returns DateRange('2013-1-1', '2014-1-1').
Usage
Returns
Date.getRange(unit,timeZone)
DateRange
Argument
Type
Details
this:date
Date
unit
String
One of 'year', 'month', 'week', 'day', 'hour', 'minute', or 'second'.
timeZone
String, default: null
The time zone (e.g., 'America/Los_Angeles'); defaults to UTC.
[[["Easy to understand","easyToUnderstand","thumb-up"],["Solved my problem","solvedMyProblem","thumb-up"],["Other","otherUp","thumb-up"]],[["Missing the information I need","missingTheInformationINeed","thumb-down"],["Too complicated / too many steps","tooComplicatedTooManySteps","thumb-down"],["Out of date","outOfDate","thumb-down"],["Samples / code issue","samplesCodeIssue","thumb-down"],["Other","otherDown","thumb-down"]],["Last updated 2025-06-23 UTC."],[[["\u003cp\u003e\u003ccode\u003eDate.getRange()\u003c/code\u003e returns a \u003ccode\u003eDateRange\u003c/code\u003e object representing the specified time unit (year, month, week, day, hour, minute, or second) that contains the input date.\u003c/p\u003e\n"],["\u003cp\u003eThe returned \u003ccode\u003eDateRange\u003c/code\u003e spans the entire unit of time, for example, if the input date is March 15, 2013, and the unit is 'year', the returned \u003ccode\u003eDateRange\u003c/code\u003e will be from January 1, 2013, to January 1, 2014.\u003c/p\u003e\n"],["\u003cp\u003eYou can optionally specify a time zone for the \u003ccode\u003eDateRange\u003c/code\u003e; if not provided, it defaults to UTC.\u003c/p\u003e\n"],["\u003cp\u003eThis function is useful for creating time-based filters or selecting data within specific time intervals.\u003c/p\u003e\n"]]],[],null,["# ee.Date.getRange\n\nReturns a DateRange covering the unit of the specified type that contains this date, e.g., Date('2013-3-15').getRange('year') returns DateRange('2013-1-1', '2014-1-1').\n\n\u003cbr /\u003e\n\n| Usage | Returns |\n|-------------------------------------|-----------|\n| Date.getRange`(unit, `*timeZone*`)` | DateRange |\n\n| Argument | Type | Details |\n|--------------|-----------------------|-----------------------------------------------------------------------|\n| this: `date` | Date | |\n| `unit` | String | One of 'year', 'month', 'week', 'day', 'hour', 'minute', or 'second'. |\n| `timeZone` | String, default: null | The time zone (e.g., 'America/Los_Angeles'); defaults to UTC. |\n\nExamples\n--------\n\n### Code Editor (JavaScript)\n\n```javascript\nvar date = ee.Date('2021-4-30T07:15:31.24');\n\nprint('1-year date range covering input date', date.getRange('year'));\nprint('1-month date range covering input date', date.getRange('month'));\nprint('1-week date range covering input date', date.getRange('week'));\nprint('1-day date range covering input date', date.getRange('day'));\nprint('1-hour date range covering input date', date.getRange('hour'));\nprint('1-minute date range covering input date', date.getRange('minute'));\nprint('1-second date range covering input date', date.getRange('second'));\n```\nPython setup\n\nSee the [Python Environment](/earth-engine/guides/python_install) page for information on the Python API and using\n`geemap` for interactive development. \n\n```python\nimport ee\nimport geemap.core as geemap\n```\n\n### Colab (Python)\n\n```python\ndate = ee.Date('2021-4-30T07:15:31.24')\n\ndisplay('1-year date range covering input date:', date.getRange('year'))\ndisplay('1-month date range covering input date:', date.getRange('month'))\ndisplay('1-week date range covering input date:', date.getRange('week'))\ndisplay('1-day date range covering input date:', date.getRange('day'))\ndisplay('1-hour date range covering input date:', date.getRange('hour'))\ndisplay('1-minute date range covering input date:', date.getRange('minute'))\ndisplay('1-second date range covering input date:', date.getRange('second'))\n```"]]