| Print Open PDF Version of Online Help

#### ToChar The ToChar function in Expression Builder converts a specified date or numeric expression to a formatted string. ### Syntax ToChar(expression, format) CAUTION: Do not use both date formats and number formats in an instance of the ToChar function. Doing so can lead to invalid results. ### Result Type String ### Arguments The following table describes the arguments for the function.
Argument | Description
--- | ---
expression | An expression or field that returns a date, date and time, or a numeric value.
format | A string that represents the date or number format.
The following table describes the date formats for the function.
Format Code | Description
--- | ---
DD | A two-digit day of month (01-31).
DDDD dddd | The name of the day.
MM | A two-digit month number (01-12 where 01 is JAN). You must use MM in uppercase, because mm in lowercase indicates minutes.
MMMM mmmm | The name of the month. Note that if you use lowercase, you must use mmmm (that is, the letter m in lowercase, four times), because mm (that is, the letter m in lowercase, twice) indicates minutes.
Y | The last digit of the year.
YY | The last two digits of the year.
YYYY | A four-digit year.
hh12 | The hour of day in 12-hour format.
hh24 | The hour of day in 24-hour format.
hh | The hour of the day. You can specify AM or PM to adjust the time accordingly, for example: hh:mm:ss PM If you do not specify AM or PM, the 24-hour format is used by default.
mm | The minutes. Note that mm (that is, the letter m in lowercase, twice) always indicates minutes and cannot be used to specify a two-digit day of the month.
ss | The seconds.
The following table describes the number formats for the function.
Format Code | Example | Description
--- | --- | ---
# | #### | Returns the value with the specified number of digits, with a leading minus sign if the value is negative.
0 | ####.00 | Returns leading zeros. Returns trailing zeros.
$ | $###.00 | Returns the value with a leading dollar sign.
, | #,### | Returns a comma in the specified position. A comma cannot appear to the right of the decimal point. The format model must not begin with a comma.
. | ###.## | Returns a decimal point in the specified position. Only one decimal point is allowed in the format parameter. If the number of digits specified after the decimal point is less than the number of digits available after the decimal point, the decimal will be rounded up.
### Examples Using Number Formats The following example returns the value 10: ToChar (10, '##.##') The following example returns the value 10: ToChar (10, '##.00') The following example returns the value 10.24: ToChar (10.2388, '##.00') The following example returns the value -10.24 ToChar (-10.2388, '##.##') ### Examples Using Date Formats The following example converts the value returned by the Timestamp() function into DD/MM/YYYY format: ToChar(Timestamp(),'DD/MM/YYYY') For example, if the Timestamp() function returns a value of 02/29/2008 10:58:37, the previous expression evaluates to 29/02/2008. The following examples show how midnight is shown using various formats: ToChar(Today(), YYYY/MM/DD hh:mm:ss PM) returns 2009/05/22 12:00:00 AM ToChar(Today(), YYYY/MM/DD hh:mm:ss) returns 2009/05/22 00:00:00 ToChar(Today(), YYYY/MM/DD hh24:mm:ss PM) returns 2009/05/22 00:00:00 #### Related Topics See the following topics for related Expression Builder information: About Expression Builder Using Expression Builder Expression Builder Functions

Published August 2022 | Copyright © 2005, 2022, Oracle and/or its affiliates. Legal Notices.