In DuckDB, ISFINITE()
is a function for checking whether values are finite. DuckDB supports infinite values, and so we can use this function to check whether a value is infinite or not. This can be useful when working with floating-point data that might contain special values like NaN (Not a Number) or infinity. We can also use it on date and timestamp values.
Tag: dates
2 Ways to Add Years to a Date in DuckDB
DuckDB provides us with an easy way to add one or more time intervals to date values. This includes adding one or more years to a date.
Here are two options for adding one or more years to a date in DuckDB.
Continue readingFix “Not implemented Error: Unknown TimeZone” in DuckDB
If you’re getting an error that reads “Not implemented Error: Unknown TimeZone” in DuckDB, it appears that you’re using an unknown timezone when specifying a timezone for a timestamp value.
To fix this issue, be sure to use a supported timezone.
Continue readingGetting a List of Time Zones in DuckDB
Sometimes we need to specify a time zone when constructing timestamp values in DuckDB. But we may not always know the exact value to use for the time zone.
Fortunately, we can use the pg_timezone_names()
table function to get a list of available timezones in DuckDB.
The Difference Between AGE() and DATE_DIFF() in DuckDB
Both AGE()
and DATE_DIFF()
are DuckDB functions used to calculate time differences, but they serve distinct purposes and exhibit different behaviors that are important to understand when working with temporal data.
This article explores the difference between these two functions.
Continue readingUsing MAKE_DATE() to Construct a Date in DuckDB
In DuckDB, the make_date()
function enables us to create date values from individual year, month, and day components. This function is particularly useful when working with data that stores date components separately or when constructing date values programmatically.
4 Functions that Get the Week From a Date in DuckDB
Working with dates often requires extracting specific components, such as the week number, for analysis or reporting. In DuckDB, there are multiple functions to retrieve the week from a date, each catering to different needs. This article explores four such functions, including how to calculate the ISO week—a standard defined by ISO-8601 where weeks start on Monday and the first week of the year contains the year’s first Thursday.
Continue readingFix “Unrecognized format for strftime/strptime: %” in DuckDB
If you’re getting an error that includes the text “Unrecognized format for strftime/strptime: %” in DuckDB, it appears that you’re including an unescaped percent sign (%
) in your format string when using a function like strftime()
or strptime()
.
Whenever we need a percent sign to be included in the formatted output, we must escape it with another percent sign in the format string.
So to fix this issue, try escaping the percent sign with another percent sign.
Continue readingAdd Hours to a Date/Time Value in DuckDB
DuckDB provides us with a range of functions and operators that we can use to manipulate date, time, and timestamp values. One basic operation you might find yourself having to perform is date/time arithmetic, such as adding one or more hours to a date/time value.
Below are two methods we can use in order to add one or more hours to a date, timestamp, or time value.
Continue readingFormatting Dates with STRFTIME() in DuckDB
In DuckDB, the strftime()
function is a handy tool for formatting date and timestamp values as strings. It accepts the date/timestamp value and a format string as arguments. The function then returns the date/time in the format provided by the format string.