Convert a Table to a JSON Document with JSON_GROUP_OBJECT() in DuckDB

In DuckDB, the json_group_object() function is a convenient way to aggregate data into JSON objects by pairing keys and values across rows within groups.

The function is especially useful when we’re transforming tabular data into a more hierarchical or nested JSON structure for web APIs, reporting, or downstream processing. It helps pivot rows into a single JSON object, making the data more compact and easier to consume in applications that require JSON formats.

Read more

2 Ways to Get the Month Name from a Date in DuckDB

DuckDB offers a pretty good range of functions that enable us to get date parts from date or timestamp value. For example, we can extract the month part from a given date value. In most cases, this will be the month number, for example 08 or just 8.

But sometimes we might want to get the actual month name, like October for example. And other times we might just want the abbreviated month name, like Oct.

Fortunately, DuckDB’s got our back. Here are two ways to return the month name from a date or timestamp value in DuckDB.

Read more

DUCKDB_TABLES() Examples

The duckdb_tables() function is a system function in DuckDB that provides useful metadata about all tables in your database. The function returns a table containing information about each table, including its schema, name, and various properties. It can be quite a handy tool for database introspection and management.

Read more

Generating Date Ranges with DuckDB Queries

Working with date ranges is a common requirement in data analysis, reporting, and time-series operations. DuckDB provides us with several approaches for generating date ranges. This article explores various techniques for creating date ranges in DuckDB.

Read more

6 Functions for Working with the Unix Epoch in DuckDB

DuckDB offers a versatile set of functions to handle timestamps at various levels of precision. This article explores some of DuckDB’s functions that help us to convert between epoch representations and timestamps.

These specialized time conversion functions can be handy tools when working with temporal data, allowing seamless translation between human-readable timestamps and machine-optimized epoch representations at varying levels of precision.

Read more

The Difference Between DATE_DIFF() and DATE_SUB() in DuckDB

In DuckDB, the date_diff() (along with its synonym datediff()) and date_sub() (along with its synonym datesub()) functions allow us to get the difference between two dates. While they might seem similar, they actually calculate date differences in distinct ways that are important to understand for accurate data analysis.

Let’s take a look at the difference between these functions.

Read more