DuckDB has a date_add()
function, which allows us to add a specified time interval to a date or timestamp. This article looks at how the date_add()
function works in DuckDB, including its syntax, usage, and examples.
Tag: date functions
A Quick Look at DuckDB’s CURRENT_DATE Function
DuckDB is an in-process SQL OLAP database management system designed for analytical workloads. It is known for its speed, efficiency, and ease of use. One of the many functions DuckDB provides is current_date
, which is useful for working with date-related data.
In this article, we’ll look at how the current_date
function works, along with some straightforward examples.
An Overview of the DATE_SUBTRACT() Function in PostgreSQL
PostgreSQL 16 introduced the date_subtract()
function that allows us to subtract an interval from a timestamp with time zone.
It computes times of day and daylight-savings adjustments according to the time zone named by the third argument, or the current TimeZone
setting if that is omitted.
PostgreSQL DATE_ADD() Function Explained
PostgreSQL 16 introduced the date_add()
function that allows us to add an interval to a timestamp with time zone.
It computes times of day and daylight-savings adjustments according to the time zone named by the third argument, or the current TimeZone
setting if that is omitted.
Understanding the DATE_BUCKET() Function in SQL Server
The release of SQL Server 2022 came with the introduction of the DATE_BUCKET()
function.
The DATE_BUCKET()
function allows us to arrange data into groups that represent fixed intervals of time. It returns the date/time value that corresponds to the start of each date/time bucket, as defined by the arguments passed to the function.
An Introduction to the DATETRUNC() Function in SQL Server
In SQL Server, we can use the DATETRUNC()
function to truncate a date/time value to a specified precision.
For example, we could use it to truncate a date value like 2024-10-25 to 2024-01-01, or a time value like 10:35:12 to 10:00:00.
The DATETRUNC()
function was introduced in SQL Server 2022Â (16.x).
7 Functions that Separate Hours, Minutes, Seconds, & Microseconds from a Time Value in MySQL
Below are seven functions we can use to extract the hours, minutes, seconds, and microseconds from a time value in MySQL.
Continue readingThree ISDATE() Alternatives that Work with DATETIME2 Values in SQL Server
SQL Server’s ISDATE()
function checks whether or not an expression is a valid date. However, you may be aware that this function doesn’t work on datetime2 values. On datetime2 values it returns 0
, which means it’s not a valid date, even when the value is a valid date.
This is obviously not ideal, because the datetime2 type is a valid date type. Microsoft even recommends that we use datetime2 instead of datetime for our dates, as it aligns with the SQL Standard and it provides more fractional seconds precision.
Anyway, below are three options we can use to check whether a datetime2 value is a valid date.
Continue readingMySQL Date & Time Functions (Full List)
The following is a list of date and time functions available in MySQL. Click on each function name to see an explanation of the function, its syntax, and examples.
Continue readingFix Error Msg 8116 “Argument data type datetime2 is invalid for argument 1 of isdate function” in SQL Server
If you’re getting an error that reads Argument data type datetime2 is invalid for argument 1 of isdate function, it’s because you’re passing a datetime2 value to the ISDATE()
function, but this function doesn’t work with datetime2 values.
To fix this issue, either pass a valid date type or use the work around below to provide similar functionality that works with datetime2 values.
Continue reading