How to Remove Leading Zeros From Dates in Oracle

In Oracle Database, you can use the fm (fill mode) format modifier to suppress any leading zeroes that might be applied to a date. This format modifier suppresses padding, which includes leading zeros and trailing blanks.

To use the fm format modifier, include it in your format model when specifying how dates should be formatted. For example when using the TO_CHAR() function to format dates, or in NLS parameters such as the NLS_DATE_FORMAT parameter when setting the date format for your current session.

Continue reading

SQL LPAD()

In SQL, LPAD()is a commonly used function that pads the left part of a string with a specified character. The function can be used on strings and numbers, although depending on the DBMS, numbers may have to be passed as a string before they can be padded.

DBMSs that have an LPAD() function include MySQL, MariaDB, PostgreSQL, and Oracle.

DBMSs that don’t have an LPAD() function include SQL Server and SQLite (although there are other ways to apply left padding in these DBMSs).

Continue reading

SQL RPAD()

In SQL, RPAD()is used to pad the right part of a string with a specified character. The function can be used on strings and numbers, although depending on the DBMS, numbers may have to be passed as a string before they can be padded.

DBMSs that have an RPAD() function include MySQL, MariaDB, PostgreSQL, and Oracle.

DBMSs that don’t have an RPAD() function include SQL Server and SQLite.

Continue reading