Oracle Database provides the TO_CHAR(number)
function that enables you to format numbers based on a given format model. There are three format elements that you can use with the TO_CHAR()
function in order to return a value as a currency.
Tag: how to
3 Ways to Format a Number to 2 Decimal Places in Oracle
When using Oracle Database, you can use functions like TO_CHAR(number)
to return numbers as a string, formatted to two decimal places (or however many decimal places you require).
Or you can use functions like ROUND(number)
and TRUNC(number)
to round or truncate the number to your required number of decimal places.
2 Ways to Get the Minutes from a Datetime Value in Oracle Database
Below are two functions that can be used to return the minutes portion from a datetime value in Oracle Database.
Continue readingHow to Get the Short Month Name from a Date in MariaDB
In MariaDB, you can use the DATE_FORMAT()
function to return various date parts from a date. One of the things you can return is the short month name. For example Nov
or Dec
(instead of November
or December
).
How to Add the Meridiem Indicator (AM/PM) to a Time Value in Oracle
When using the TO_CHAR()
function to format a datetime value in Oracle Database, you can add the meridiem indicator (AM/PM) by simply adding either AM
or PM
to your format model.
Oracle then displays the appropriate meridiem indicator, depending on whether the time value is AM or PM.
You can provide it in any uppercase or lowercase, and with or without dots (e.g. AM
, A.M.
am
, a.m
, etc). Oracle will then display the meridiem indicator as specified.
5 Functions to Extract the Week Number from a Date in MariaDB
Below are 5 functions that enable you to return the week number from a date in MariaDB. Four return just the week, and one returns both the week and year combined.
Continue readingHow to Change your Session’s Currency Symbol in Oracle
In Oracle Database, there are a few different NLS parameters that determine how currency is displayed when using functions like TO_CHAR()
to format a number as a currency.
NLS_CURRENCY
specifies the string to use as the local currency symbol for theL
number format element.NLS_ISO_CURRENCY
determines what to use for theC
format element.NLS_DUAL_CURRENCY
specifies what to use for theU
format element.
Get the Current Login ID in SQL Server (T-SQL)
You can use the SUSER_ID()
function to return the login identification number of the current user.
You can also use it to return the login ID of another user.
This is similar to returning the current login name, except here we’re returning the ID instead.
Continue reading2 Functions that Return the Month from a Date in Oracle
Below are two functions that can be used to extract the month from a date in Oracle Database.
Continue reading6 Ways to Check your MariaDB Version
Here are six ways to check what version of MariaDB you’re currently running.
Continue reading