Here are some options for subtracting one or more microseconds from a datetime expression in MariaDB.
Continue readingTag: dates
How to Remove the Trailing Spaces after the Month Name in Oracle
If you’ve ever used the TO_CHAR()
function to format a date that uses the month name, you might have noticed that sometimes the month is returned with right padding.
3 Ways to Separate the Year, Month, and Day from a Date in MariaDB
MariaDB has several functions that enable you to extract various date and time parts from date/time values. You can use these to separate each date/time component into its own column if required.
Below are three ways to extract the year, month, and day from a date value in MariaDB.
Continue reading8 Ways to Add an Hour to a Datetime in MariaDB
There are many ways to perform date arithmetic in MariaDB. This includes adding or subtracting a certain number of a given date part from a date or datetime value.
In this article, I present 8 ways to add an hour to a datetime value in MariaDB.
Continue readingAdd a Time Zone Offset to a datetime2 Value in SQL Server (T-SQL)
In SQL Server, the TODATETIMEOFFSET()
function was specifically designed to return a datetimeoffset value from a datetime2 value.
Given the fact that the datetime2 data type doesn’t actually support time zone offsets, and datetimeoffset must contain the offset, the TODATETIMEOFFSET()
function allows you to specify a time zone offset to use.
This article provides some examples to demonstrate.
Continue readingHow to Get the Day, Month, and Year from a Date in SQL
Most of the major RDBMSs have functions that enable us to extract the day, month, and year from datetime values.
Some RDBMSs provide multiple ways to do this, and others are more limited. Below are examples of extracting the day, month, and year from date values in some of the most popular RDBMSs.
Continue readingDate & Time Units in MySQL (Full List)
Here’s a list of units that can be used in MySQL datetime and interval functions.
Continue reading2 Functions that Get the Day, Month, and Year from a Date in Oracle
Oracle Database has the TO_CHAR(datetime)
function that enables us to get various date parts from a datetime value.
There’s also the EXTRACT(datetime)
function that extracts a specific datetime unit (e.g. day, month, year, etc).
How to Extract the Day, Month, and Year from a Date in SQLite
In SQLite, we can use the strftime()
function to return datetime values in our chosen format.
Therefore, we can use it to extract the day, month, and year from a date.
Continue reading3 Functions that Get the Day, Month, and Year from a Date in PostgreSQL
PostgreSQL provides us with several ways to get the day, month, and year from a date.
Three functions that immediately come to mind are; DATE_PART()
, EXTRACT()
, and TO_CHAR()
.