In SQLite, we can use the DATE() function to subtract one or more years from a date.
For datetime values, we can use the DATETIME() function.
In SQLite, we can use the DATE() function to subtract one or more years from a date.
For datetime values, we can use the DATETIME() function.
The + operator allows us to add one or more days to a given date in PostgreSQL. We have a few options when it comes to specifying the actual number of days.
SQLite doesn’t have a DATEADD() function like SQL Server (or an ADDDATE() or ADD_DATE() function like in some other DBMSs), but it does have the DATE() function that can make additions to a date value.
SQLite also has a DATETIME() function that can make additions to a datetime value (as well as a TIME() function for time values).
We can subtract one or more days from a date in PostgreSQL with the - operator.
Updated 20 April 2024 to include the date_add() function.
SQL Server has its DATEADD() function that adds an interval to a date value. MySQL’s DATE_ADD() and ADDDATE() for does the same thing, as does MariaDB’s DATE_ADD() and ADDDATE(). SQLite has a DATE() function that also provides the option of adding an interval to a given date.
Prior to version 16, PostgreSQL didn’t have a DATEADD() or equivalent function. But with PostgreSQL 16 came with the introduction of the date_add() function, which allows us to add an interval to a timestamp with time zone.
We can also add and subtract values from dates with date/time operators such as + and -.
Oracle Database provides us with the ability to return the month from a date using roman numerals.
For example, if the month is August, its decimal value would be 08 and it’s roman numeral equivalent would be VIII.
The way to do this is to use the RM or rm format element in your format mask. That will format the month using roman numerals in uppercase or lowercase respectively.
Specifying the date format can be done in several places.
In Oracle Database, when using the TO_CHAR() function to return the day name from a date, padding will be appended to the day name if it’s shorter than the longest valid day name for the given language and calendar.
Well, that’s the default behaviour. However, you can change this if you wish.
To suppress this padding, all you need to do is prepend the day name format element with fm.
MariaDB includes a large collection of date and time functions that return a given date in a certain format.
One thing you can do is return the day number with the relevant “st/nd/rd/th” suffix. For example, instead of returning it as say, 10 July 2025, it’s returned as 10th July 2025.
Below is an example of adding the relevant suffix to a day number in MariaDB.
In MariaDB, you can use the DATE_FORMAT() function to return the month name and day name from a date.
This function accepts an optional argument that let’s you specify the language that is used for the result.
Here are some options for subtracting one or more hours from a datetime value in MariaDB.