substr()
A function that returns part of a text value, given a start position and a length.
In more detail
substr(ordered_on, 1, 7) takes the first seven characters of a date stored as year-month-day text, which is the year and month. The course uses it to group orders by month in SQLite, where there is no date type.
Related terms
- date() — SQLite functions that do calendar arithmetic and formatting on dates stored as year-month-day text.
- ISO 8601 date format — The international standard for writing dates and times as text, such as 2024-01-15T10:00:00Z.
Taught in
- Grouping By Multiple Columns — PostgreSQL, Indexing & Relational Data Modeling