Below are examples that demonstrate how to use SQL to return the short month name from a date in the major RDBMSs.
Continue readingCategory: Oracle
2 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).
2 Ways to Format your Query Results in SQLcl (Oracle)
When using SQLcl to run queries against Oracle Database, you can specify the output of the query results using the following two options:
- The
SET SQLFORMAT
command - Add a comment shortcut to your query
How to Format Numbers with a Minus/Plus Sign in Oracle
When using the TO_CHAR()
function to format a number in Oracle Database, you can use the S
format element to return its sign (i.e. a plus sign for positive values, and a minus sign for negative values).
You can also use the MI
format element to return negative values with a trailing negative sign, and positive values with a trailing blank.
Export Query Results to an XML File when using SQLcl (Oracle)
When using SQLcl with Oracle Database, you can export your query results to an XML file with the SPOOL
command.
Get the Month Name from a Date in SQL
Most major RDBMSs provide at least one function that enables us to return the month name from a date.
Continue reading2 Ways to Concatenate a String and a Number in Oracle
In Oracle Database, we can concatenate strings and numbers with the CONCAT()
function or the pipe concatenation operator (||
).
How to Format Numbers in Oracle
In Oracle Database, you can format numbers in many ways.
For example, you can format a number as a currency, with commas and decimal points in the right place. You can specify leading zeros, you can add a fractional part – or remove it, if that’s what’s required.
Continue readingReturn the Short Day Name from a Date in Oracle
In Oracle Database, we can use the TO_CHAR(datetime)
function to return the various date parts from a datetime value, including the short day name.
The short day name is also referred to as the abbreviated day name. In any case, below are examples of returning the short day name from a date value in Oracle.
Continue readingList of Territories Supported by Oracle Database
Below is a list of territories that are supported by Oracle Database. These can be used when setting the NLS_TERRITORY
initialization parameter.