If you’re getting an error that reads “Error: Month out of range, expected a value between 1 and 12” when using the strptime()
function in DuckDB, it could be that you’re getting your months mixed up in your format string.
Category: DBMS
Database Management Systems
A Quick Look at the SUM() Function in DuckDB
One of the more commonly used aggregate functions in SQL databases is the sum()
function, which provides an easy way to calculate the total sum of a numeric column. DuckDB is no exception.
In this article, we’ll explore how the sum()
function works in DuckDB, along with some straightforward examples to demonstrate.
How to Check a Table for Unique Indexes in SQLite
Being able to ensure uniqueness in database tables is critical for maintaining data integrity. SQLite allows us to create unique indexes in order to enforce uniqueness, and it provides us with tools to check the unique indexes associated with a table.
This article outlines how to use the SQLite PRAGMA index_list()
command to check a table for unique indexes.
7 Functions that Extract the Day from a Date in DuckDB
When working with dates in DuckDB, extracting specific components like the day is a common task. DuckDB provides a good range of functions that we can use to help us to perform such a task.
This article presents seven different functions we can use to extract the day from a date in DuckDB.
Continue readingHow to Format Dates in DuckDB
When working with SQL databases such as DuckDB, dates usually conform to a specific format. In particular, when we create dates in DuckDB, they must conform to the ISO 8601 format (YYYY-MM-DD
). It’s the same with time (hh:mm:ss[.zzzzzz][+-TT[:tt]]
) and timestamp values (YYYY-MM-DD hh:mm:ss[.zzzzzzzzz][+-TT[:tt]]
).
But what if we have a requirement to present these dates or timestamps in a different format?
Fortunately, DuckDB provides us with tools to so. This article explains how to format date and timestamp values according to a specified format.
Continue readingSubtracting One or More Years from a Date in DuckDB
Sometimes we need to subtract a certain time interval from a date when working with DuckDB. We might want to subtract hours, minutes, days, months, or even years.
Below are two methods we can use to subtract one or more years from a date in DuckDB.
Continue readingA Quick Look at the LIST() Function in DuckDB
DuckDB, an in-memory analytical SQL database management system, provides a good selection of functions for data manipulation and analysis. One of the these functions is list()
.
The list()
function enables users to group multiple values into a single list, allowing for more advanced data aggregation and operations.
In this article, we’ll explore how the list()
function works, along with some simple examples.
Fix “Binder Error: APPROXIMATE QUANTILE can only take parameters in range [0, 1]” in DuckDB
If you’re getting an error that reads “Binder Error: APPROXIMATE QUANTILE can only take parameters in range [0, 1]” in DuckDB, it appears that you’re passing an invalid second argument to the approx_quantile()
function.
To fix this issue, make sure the second argument is between 0 and 1.
Continue readingList of DuckDB Format Specifiers for Date Formats
In DuckDB, we can use functions like strftime()
and strptime()
to format date or timestamp values. These functions accept a format string that specifies how the date or timestamp should be formatted.
The format string consists of one or more format specifiers. For example, '%d/%m/%Y'
is a format string that consists of three format specifiers. The output from that format specifier might look something like 05/09/2050.
How MIN_BY() Works in DuckDB
DuckDB has a min_by()
function that’s similar to the min()
function, but with a twist. While the min()
function simply returns the minimum value, the min_by()
function finds the row with the minimum value in one column and returns the corresponding value from another column at that row.
Here are some examples that demonstrate how it works.
Continue reading