In MySQL, the FORMAT()
function returns a number formatted to a specified number of decimal places.
It includes group separators and a decimal separator where applicable.
Continue readingIn MySQL, the FORMAT()
function returns a number formatted to a specified number of decimal places.
It includes group separators and a decimal separator where applicable.
Continue readingBelow are examples that demonstrate how to use SQL to return the short month name from a date in the major RDBMSs.
Continue readingHere’s a list of units that can be used in MySQL datetime and interval functions.
Continue readingThere are a couple of approaches we can use to concatenate strings and numbers in MySQL.
CONCAT()
function, which concatenates its arguments.||
), which concatenates its operands.Below are examples of each.
Continue readingMySQL supports the use of the pipe concatenation operator (||
) for concatenating its operands. However, you need to enable it first.
MySQL has a bunch of different functions that enable us to get various date parts – such as the day, month, and year – from a date.
Continue readingIn MySQL, YEAR()
is a built-in date and time function that returns the year from a given date expression.
It returns the year as a number in the range 1000
to 9999
. For zero dates, it could return 0
or NULL
with a warning, depending on the values in your sql_mode
.
Some DBMSs provide us with the ability to format a number as a currency by providing a format specifier for the currency symbol. Providing such a format specifier allows the DBMS to return the appropriate currency symbol for the locale.
MySQL doesn’t have a currency format specifier, and so we need to do a bit of extra work if we want the currency symbol to be returned.
Continue readingBelow are the steps that I used to install MySQL on my M1 Mac via the Homebrew package manager.
As mentioned, this is an M1 Mac (which uses the ARM64 architecture) but that didn’t cause any issues. The current version (MySQL 8.0.26) supports the ARM architechure.
Continue readingIn MySQL, you can use the DATE_FORMAT()
function with the %b
format specifier to return the short month name. For example, you can return Jan
or Feb
instead of January
or February
.