How ADDTIME() Works in MariaDB

In MariaDB, ADDTIME() is a built-in date and time function that adds an amount to a time or datetime expression.

It allows you to change a time or datetime expression by passing that expression, as well as a time expression to add to that expression. You can pass a negative amount if you need to subtract from the time expression.

Read more

How SUBTIME() Works in MariaDB

In MariaDB, SUBTIME() is a built-in date and time function that subtracts an amount from a time or datetime expression.

It allows you to change a time or datetime expression by passing that expression, as well as a time expression to subtract from that expression. You can pass a negative amount if you need to add to the time expression.

Read more

How SUBDATE() Works in MariaDB

In MariaDB, SUBDATE() is a built-in date and time function that subtracts an amount from a given date.

It allows you to change a date by specifying the date, the unit to subtract, and the amount to subtract. You can pass a negative amount in order to add to the date, instead of subtracting from it.

SUBDATE() also has a shortcut syntax that allows you to specify the days to subtract.

Read more

How DATE_SUB() Works in MariaDB

In MariaDB, DATE_SUB() is a built-in date and time function that allows you to subtract an amount from a date.

It allows you to change a date by specifying the date, the unit to subtract, and the amount to subtract. You can pass a negative amount in order to add to the date, instead of subtracting from it.

Read more

How ADDDATE() Works in MariaDB

In MariaDB, ADDDATE() is a built-in date and time function that performs date arithmetic.

It allows you to change a date by specifying the date, the unit to add, and the amount to add. You can pass a negative amount if you need to subtract the date by a certain interval.

ADDDATE() also has a shortcut syntax that allows you to add a given number of days to the date.

Read more

How DATE_ADD() Works in MariaDB

In MariaDB, DATE_ADD() is a built-in date and time function that performs date arithmetic.

It allows you to change a date by specifying the date, the unit to add, and the amount to add. You can pass a negative amount if you need to subtract the date by a certain interval.

Read more

Calculate the Age in Years in PostgreSQL

Postgres has the age() function that returns the age in years, months, and days based on two dates.

This works fine unless you only want to return the age in years.

For example, you simply want to return a person’s age based on their birthday. You want something like 32 instead of 32 years 4 mons 67 days, which is what age() is likely to return.

Fortunately there’s an easy way to do this in PostgreSQL.

Read more