### Install sqlite-utils-dateutil Plugin Source: https://github.com/simonw/sqlite-utils-dateutil/blob/main/README.md Installs the sqlite-utils-dateutil plugin using pip. This command should be run in the same environment where sqlite-utils is installed. ```bash sqlite-utils install sqlite-utils-dateutil ``` -------------------------------- ### Set up Local Development Environment for sqlite-utils-dateutil Source: https://github.com/simonw/sqlite-utils-dateutil/blob/main/README.md Provides instructions for setting up the development environment for the sqlite-utils-dateutil plugin. This includes creating a virtual environment, installing dependencies, and running tests. ```bash cd sqlite-utils-dateutil python3 -m venv venv source venv/bin/activate pip install -e '.[test]' pytest ``` -------------------------------- ### Python API Usage Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Demonstrates how to use the date utility functions when sqlite-utils is used as a Python library. Functions are automatically available after installing the plugin. ```APIDOC ## Python API Usage ### Description When using sqlite-utils as a Python library, all date functions are automatically available after installing the plugin. The functions can be called within any SQL query executed through the Database object. ### Method Python Library Integration ### Endpoint N/A (Python API) ### Parameters N/A ### Request Example ```python import sqlite_utils import json # Create an in-memory database (functions auto-registered) db = sqlite_utils.Database(memory=True) # Parse various date formats result = db.execute("select dateutil_parse('next thursday')").fetchone()[0] print(f"Parsed date: {result}") # Extract dates from text result = db.execute("select dateutil_parse_fuzzy('Invoice dated 15th March 2024')").fetchone()[0] print(f"Extracted: {result}") # 2024-03-15T00:00:00 # Generate recurring dates rrule_result = db.execute( "select dateutil_rrule('FREQ=WEEKLY;BYDAY=MO,WE,FR;COUNT=6', '2024-01-01')" ).fetchone()[0] dates = json.loads(rrule_result) print(f"Meeting dates: {dates}") # Use in queries with tables db.execute("create table events (name text, date_text text)") db.execute("insert into events values ('Meeting', 'next monday'), ('Deadline', '15 march 2024')") for row in db.query("select name, dateutil_parse(date_text) as parsed_date from events"): print(row) ``` ### Response #### Success Response (Python Output) - **Printed Output** - The output will vary based on the executed queries and the current date. #### Response Example ``` Parsed date: 2024-03-21T00:00:00 Extracted: 2024-03-15T00:00:00 Meeting dates: ['2024-01-01T00:00:00', '2024-01-03T00:00:00', '2024-01-05T00:00:00', '2024-01-08T00:00:00', '2024-01-10T00:00:00', '2024-01-12T00:00:00'] {'name': 'Meeting', 'parsed_date': '2024-03-18T00:00:00'} {'name': 'Deadline', 'parsed_date': '2024-03-15T00:00:00'} ``` ``` -------------------------------- ### Parse Date String with dateutil_parse SQL Function Source: https://github.com/simonw/sqlite-utils-dateutil/blob/main/README.md Demonstrates how to use the `dateutil_parse` SQL function provided by the plugin. It takes a date string as input and returns a formatted date-time string. This example uses `sqlite-utils` in memory mode. ```bash sqlite-utils memory "select dateutil_parse('10 october 2020 3pm')" --table ``` -------------------------------- ### dateutil_rrule Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Expands iCalendar recurrence rules (RFC 5545 RRULE) into a JSON array of datetime strings. Supports specifying the start date either within the RRULE string or as a separate second argument. Limited to 10,000 results maximum to prevent memory issues. ```APIDOC ## dateutil_rrule ### Description Expands iCalendar recurrence rules (RFC 5545 RRULE) into a JSON array of datetime strings. Supports specifying the start date either within the RRULE string or as a separate second argument. Limited to 10,000 results maximum to prevent memory issues. ### Method SQL Function ### Endpoint N/A (SQL Function) ### Parameters #### SQL Arguments - **rrule_string** (TEXT) - Required - The iCalendar RRULE string, optionally including DTSTART. - **dtstart** (TEXT) - Optional - The start date if not included in the rrule_string. ### Request Example ```bash sqlite-utils memory "select dateutil_rrule('DTSTART:20200101\nFREQ=DAILY;INTERVAL=10;COUNT=5')" --table sqlite-utils memory "select dateutil_rrule('FREQ=DAILY;INTERVAL=10;COUNT=5', '2020-01-01')" --table ``` ### Response #### Success Response (SQL Result) - **JSON Array of Datetime Strings** (TEXT) - A JSON array containing the generated datetime strings. #### Response Example ```json ["2020-01-01T00:00:00", "2020-01-11T00:00:00", "2020-01-21T00:00:00", "2020-01-31T00:00:00", "2020-02-10T00:00:00"] ``` ``` -------------------------------- ### Expand RRULE with dateutil_rrule Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Expands iCalendar recurrence rules (RFC 5545 RRULE) into a JSON array of datetime strings. Supports specifying the start date either within the RRULE string or as a separate second argument. Limited to 10,000 results maximum. ```bash # Generate dates using embedded DTSTART sqlite-utils memory "select dateutil_rrule('DTSTART:20200101 FREQ=DAILY;INTERVAL=10;COUNT=5')" --table ``` ```bash # Generate dates with separate dtstart argument sqlite-utils memory "select dateutil_rrule('FREQ=DAILY;INTERVAL=10;COUNT=5', '2020-01-01')" --table ``` ```bash # Weekly meetings for 4 weeks sqlite-utils memory "select dateutil_rrule('FREQ=WEEKLY;COUNT=4', '2024-01-01')" --table ``` ```python import sqlite_utils import json db = sqlite_utils.Database(memory=True) rrule_result = db.execute("select dateutil_rrule('FREQ=WEEKLY;BYDAY=MO,WE,FR;COUNT=6', '2024-01-01')").fetchone()[0] dates = json.loads(rrule_result) print(f"Meeting dates: {dates}") ``` -------------------------------- ### dateutil_dates_between Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Generates a JSON array of all dates between two dates. By default, the range is inclusive (includes both start and end dates). Pass 0 as the third argument for an exclusive end date. ```APIDOC ## dateutil_dates_between ### Description Generates a JSON array of all dates between two dates. By default, the range is inclusive (includes both start and end dates). Pass 0 as the third argument for an exclusive end date. ### Method SQL Function ### Endpoint N/A (SQL Function) ### Parameters #### SQL Arguments - **start_date** (TEXT) - Required - The start date of the range (natural language accepted). - **end_date** (TEXT) - Required - The end date of the range (natural language accepted). - **inclusive_end** (INTEGER) - Optional - 1 for inclusive (default), 0 for exclusive end date. ### Request Example ```bash sqlite-utils memory "select dateutil_dates_between('1 january 2020', '5 jan 2020')" --table sqlite-utils memory "select dateutil_dates_between('1 january 2020', '5 jan 2020', 0)" --table ``` ### Response #### Success Response (SQL Result) - **JSON Array of Date Strings** (TEXT) - A JSON array containing the date strings in YYYY-MM-DD format within the specified range. #### Response Example ```json ["2020-01-01", "2020-01-02", "2020-01-03", "2020-01-04", "2020-01-05"] ``` ``` -------------------------------- ### Parse Dates with dateutil_parse Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Parses various date formats, including natural language expressions, into ISO 8601 datetime strings. This function is useful for standardizing date inputs from different sources. It is automatically available when the dateutil plugin is installed. ```bash sqlite-utils memory "select dateutil_parse('next thursday')" --table ``` ```python import sqlite_utils db = sqlite_utils.Database(memory=True) result = db.execute("select dateutil_parse('next thursday')").fetchone()[0] print(f"Parsed date: {result}") ``` -------------------------------- ### Expand RRULE to Dates with dateutil_rrule_date Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Similar to `dateutil_rrule`, but returns date-only values (YYYY-MM-DD) instead of full datetime strings. This is useful when the time component is irrelevant for the generated dates. It also supports embedded or separate start dates and has a 10,000 result limit. ```bash # Generate date-only values with embedded DTSTART sqlite-utils memory "select dateutil_rrule_date('DTSTART:20200101 FREQ=DAILY;INTERVAL=10;COUNT=5')" --table ``` ```bash # Generate date-only values with separate dtstart sqlite-utils memory "select dateutil_rrule_date('FREQ=DAILY;INTERVAL=10;COUNT=5', '2020-01-01')" --table ``` ```bash # Monthly dates for a quarter sqlite-utils memory "select dateutil_rrule_date('FREQ=MONTHLY;COUNT=3', '2024-01-15')" --table ``` -------------------------------- ### Using dateutil Functions with Tables in Python Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Demonstrates how to use dateutil functions directly within SQL queries when `sqlite-utils` is used as a Python library. This allows for dynamic date processing on data stored in tables, such as parsing dates from text columns. ```python import sqlite_utils db = sqlite_utils.Database(memory=True) db.execute("create table events (name text, date_text text)") db.execute("insert into events values ('Meeting', 'next monday'), ('Deadline', '15 march 2024')") for row in db.query("select name, dateutil_parse(date_text) as parsed_date from events"): print(row) ``` -------------------------------- ### Parse Dates Day-First with dateutil_parse_dayfirst (SQL) Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Parses dates with a day-first interpretation, crucial for ambiguous formats like '1/2/2020' in regions using DD/MM/YYYY. This ensures '1/2/2020' is correctly parsed as February 1st. It supports providing a default datetime for incomplete dates. ```bash sqlite-utils memory "select dateutil_parse_dayfirst('1/2/2020')" --table ``` ```bash sqlite-utils memory "select dateutil_parse_dayfirst('1/2', '1981-01-01')" --table ``` -------------------------------- ### dateutil_parse_fuzzy_dayfirst Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Combines fuzzy text extraction with day-first date interpretation. Extracts dates from unstructured text while treating ambiguous day/month values with day-first priority. Optionally accepts a second argument as a default datetime. ```APIDOC ## dateutil_parse_fuzzy_dayfirst ### Description Combines fuzzy text extraction with day-first date interpretation. Extracts dates from unstructured text while treating ambiguous day/month values with day-first priority. Optionally accepts a second argument as a default datetime. ### Method SQL Function ### Endpoint N/A (SQL Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```sql SELECT dateutil_parse_fuzzy_dayfirst('due on 1/2/2003'); SELECT dateutil_parse_fuzzy_dayfirst('due on 1/2', '1765-01-01'); ``` ### Response #### Success Response (200) - **dateutil_parse_fuzzy_dayfirst(string)** (string) - ISO 8601 formatted datetime string or NULL. #### Response Example ```json { "dateutil_parse_fuzzy_dayfirst('due on 1/2/2003')": "2003-02-01T00:00:00" } ``` ``` -------------------------------- ### Fuzzy Date Extraction Day-First with dateutil_parse_fuzzy_dayfirst (SQL) Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Combines fuzzy date extraction from text with day-first interpretation. This function is ideal for extracting dates from unstructured text where the date format might be ambiguous (e.g., '1/2/2003') and should be treated as DD/MM/YYYY. It also accepts a default datetime. ```bash sqlite-utils memory "select dateutil_parse_fuzzy_dayfirst('due on 1/2/2003')" --table ``` ```bash sqlite-utils memory "select dateutil_parse_fuzzy_dayfirst('due on 1/2', '1765-01-01')" --table ``` -------------------------------- ### Parse Dates with dateutil_parse (SQL & Python) Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Parses various natural language and standard date formats into ISO 8601 datetime strings. It can optionally use a default datetime to fill in missing components. Returns NULL if parsing fails. This function is accessible via SQL queries and programmatically through the sqlite-utils Python library. ```bash sqlite-utils memory "select dateutil_parse('10 october 2020 3pm')" --table ``` ```bash sqlite-utils memory "select dateutil_parse('1st october', '10th september 2020')" --table ``` ```python import sqlite_utils db = sqlite_utils.Database(memory=True) result = list(db.query("select dateutil_parse('1st october 2009')")) print(result[0]) ``` -------------------------------- ### Handle Invalid Input with dateutil_easter Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Illustrates the behavior of dateutil functions when provided with invalid input. For `dateutil_easter`, an invalid input string results in a `NULL` value being returned, indicating the function could not process the input. ```bash sqlite-utils memory "select dateutil_easter('invalid')" --table ``` -------------------------------- ### dateutil_parse_dayfirst Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Parses dates with day-first interpretation for ambiguous dates like "1/2/2020". In regions using DD/MM/YYYY format, this ensures "1/2/2020" is parsed as February 1st rather than January 2nd. Optionally accepts a second argument as a default datetime. ```APIDOC ## dateutil_parse_dayfirst ### Description Parses dates with day-first interpretation for ambiguous dates like "1/2/2020". In regions using DD/MM/YYYY format, this ensures "1/2/2020" is parsed as February 1st rather than January 2nd. Optionally accepts a second argument as a default datetime. ### Method SQL Function ### Endpoint N/A (SQL Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```sql SELECT dateutil_parse_dayfirst('1/2/2020'); SELECT dateutil_parse_dayfirst('1/2', '1981-01-01'); ``` ### Response #### Success Response (200) - **dateutil_parse_dayfirst(string)** (string) - ISO 8601 formatted datetime string or NULL. #### Response Example ```json { "dateutil_parse_dayfirst('1/2/2020')": "2020-02-01T00:00:00" } ``` ``` -------------------------------- ### dateutil_parse Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Parses a date string using intelligent date parsing and returns an ISO 8601 formatted datetime string. Handles various natural language formats and standard date formats. Optionally accepts a second argument as a default datetime. ```APIDOC ## dateutil_parse ### Description Parses a date string using intelligent date parsing and returns an ISO 8601 formatted datetime string. Handles various natural language formats like "1st october 2009", "10 october 2020 3pm", and standard date formats. Returns NULL if the date cannot be parsed. Optionally accepts a second argument as a default datetime to fill in missing components. ### Method SQL Function ### Endpoint N/A (SQL Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```sql SELECT dateutil_parse('10 october 2020 3pm'); SELECT dateutil_parse('1st october', '10th september 2020'); ``` ### Response #### Success Response (200) - **dateutil_parse(string)** (string) - ISO 8601 formatted datetime string or NULL. #### Response Example ```json { "dateutil_parse('10 october 2020 3pm')": "2020-10-10T15:00:00" } ``` ``` -------------------------------- ### Extract Dates from Text with dateutil_parse_fuzzy (SQL) Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Extracts and parses dates from unstructured text that may contain additional non-date content. This is useful for finding dates embedded within sentences. It returns NULL if no valid date can be extracted. A default datetime can be provided to fill missing components. ```bash sqlite-utils memory "select dateutil_parse_fuzzy('Meeting due on 1st october 2009')" --table ``` ```bash sqlite-utils memory "select dateutil_parse_fuzzy('due on 1st october', '2020-01-01')" --table ``` -------------------------------- ### Generate Date Ranges with dateutil_dates_between Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Generates a JSON array of all dates between two specified dates. The range is inclusive by default, but can be made exclusive of the end date by passing `0` as the third argument. Accepts natural language date formats. ```bash # Inclusive date range (default) sqlite-utils memory "select dateutil_dates_between('1 january 2020', '5 jan 2020')" --table ``` ```bash # Exclusive end date sqlite-utils memory "select dateutil_dates_between('1 january 2020', '5 jan 2020', 0)" --table ``` ```bash # Natural language dates work too sqlite-utils memory "select dateutil_dates_between('december 25 2023', 'january 2 2024')" --table ``` -------------------------------- ### dateutil_easter Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Calculates the date of Easter Sunday for a given year. Returns the date in ISO 8601 format (YYYY-MM-DD). Returns NULL for invalid input. ```APIDOC ## dateutil_easter ### Description Calculates the date of Easter Sunday for a given year. Returns the date in ISO 8601 format (YYYY-MM-DD). Returns NULL for invalid input. ### Method SQL Function ### Endpoint N/A (SQL Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```sql SELECT dateutil_easter(2020); SELECT year, dateutil_easter(year) as easter FROM (SELECT 2020 as year UNION SELECT 2021 UNION SELECT 2022); ``` ### Response #### Success Response (200) - **dateutil_easter(integer)** (string) - ISO 8601 formatted date string (YYYY-MM-DD) or NULL. #### Response Example ```json { "dateutil_easter(2020)": "2020-04-12" } ``` ``` -------------------------------- ### Extract Dates with dateutil_parse_fuzzy Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Extracts the first recognizable date from a given text string. This function is helpful for pulling specific dates out of larger text blocks, like invoices or documents. It returns an ISO 8601 datetime string. ```bash sqlite-utils memory "select dateutil_parse_fuzzy('Invoice dated 15th March 2024')" --table ``` ```python import sqlite_utils db = sqlite_utils.Database(memory=True) result = db.execute("select dateutil_parse_fuzzy('Invoice dated 15th March 2024')").fetchone()[0] print(f"Extracted: {result}") ``` -------------------------------- ### dateutil_rrule_date Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Same as dateutil_rrule but returns date-only values (YYYY-MM-DD) instead of full datetime strings. Useful when time components are not needed. ```APIDOC ## dateutil_rrule_date ### Description Same as dateutil_rrule but returns date-only values (YYYY-MM-DD) instead of full datetime strings. Useful when time components are not needed. ### Method SQL Function ### Endpoint N/A (SQL Function) ### Parameters #### SQL Arguments - **rrule_string** (TEXT) - Required - The iCalendar RRULE string, optionally including DTSTART. - **dtstart** (TEXT) - Optional - The start date if not included in the rrule_string. ### Request Example ```bash sqlite-utils memory "select dateutil_rrule_date('DTSTART:20200101\nFREQ=DAILY;INTERVAL=10;COUNT=5')" --table sqlite-utils memory "select dateutil_rrule_date('FREQ=DAILY;INTERVAL=10;COUNT=5', '2020-01-01')" --table ``` ### Response #### Success Response (SQL Result) - **JSON Array of Date Strings** (TEXT) - A JSON array containing the generated date strings in YYYY-MM-DD format. #### Response Example ```json ["2020-01-01", "2020-01-11", "2020-01-21", "2020-01-31", "2020-02-10"] ``` ``` -------------------------------- ### dateutil_parse_fuzzy Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Extracts and parses dates from text containing additional non-date content. Useful for extracting dates from sentences or unstructured text where the date is embedded within other words. Returns NULL if no valid date can be extracted. Optionally accepts a second argument as a default datetime. ```APIDOC ## dateutil_parse_fuzzy ### Description Extracts and parses dates from text containing additional non-date content. Useful for extracting dates from sentences or unstructured text where the date is embedded within other words. Returns NULL if no valid date can be extracted. Optionally accepts a second argument as a default datetime. ### Method SQL Function ### Endpoint N/A (SQL Function) ### Parameters #### Path Parameters None #### Query Parameters None #### Request Body None ### Request Example ```sql SELECT dateutil_parse_fuzzy('Meeting due on 1st october 2009'); SELECT dateutil_parse_fuzzy('due on 1st october', '2020-01-01'); ``` ### Response #### Success Response (200) - **dateutil_parse_fuzzy(string)** (string) - ISO 8601 formatted datetime string or NULL. #### Response Example ```json { "dateutil_parse_fuzzy('Meeting due on 1st october 2009')": "2009-10-01T00:00:00" } ``` ``` -------------------------------- ### Calculate Easter Date with dateutil_easter (SQL) Source: https://context7.com/simonw/sqlite-utils-dateutil/llms.txt Calculates the date of Easter Sunday for a specified year. The function returns the date in ISO 8601 format (YYYY-MM-DD). It returns NULL for invalid year inputs. This function can be used to retrieve Easter dates for single or multiple years in SQL queries. ```bash sqlite-utils memory "select dateutil_easter(2020)" --table ``` ```bash sqlite-utils memory "select year, dateutil_easter(year) as easter from (select 2020 as year union select 2021 union select 2022)" --table ``` === COMPLETE CONTENT === This response contains all available snippets from this library. No additional content exists. Do not make further requests.