<!DOCTYPE html> <html lang="en-US"> <head> <base href="../../../../"> <meta http-equiv="Content-Type" content="text/html; charset=utf-8"> <title>Converting Text to Numbers</title> <link rel="shortcut icon" href="media/navigation/favicon.ico"> <link type="text/css" href="normalize.css" rel="Stylesheet"> <link type="text/css" href="default.css" rel="Stylesheet"> <link type="text/css" href="prism.css" rel="Stylesheet"> <script type="text/javascript" src="polyfills.js"></script><script type="text/javascript" src="languages.js"></script><script type="text/javascript" src="fuzzysort.js"></script><script type="text/javascript" src="prism.js"></script><script type="text/javascript" src="help2.js" defer></script><script type="text/javascript" src="a11y-toggle.js" defer></script><script type="text/javascript" src="en-US/langnames.js" defer></script><script type="text/javascript" src="paginathing.js" defer></script><script type="text/javascript" src="en-US/bookmarks.js" defer></script><script type="text/javascript" src="en-US/contents.js" defer></script><script type="text/javascript" src="help.js" defer></script><meta name="viewport" content="width=device-width,initial-scale=1"> </head> <body itemscope="true" itemtype="http://schema.org/TechArticle"> <div class="header-extrawurst"> <header><div class="logo-container"><a class="logo" href="en-US/text/shared/05/new_help.html"><div class="symbol"></div> <p>LibreOffice 6.4 Help</p></a></div></header><div class="modules"> <button type="button" data-a11y-toggle="modules-nav" id="modules" onclick="setupModules('', 'en-US');">Module</button><nav id="modules-nav"></nav> </div> </div> <aside class="rightside"><input id="accordion-1" name="accordion-menu" type="checkbox"><label for="accordion-1">Contents</label><div id="Contents" class="contents-treeview"></div></aside><aside class="leftside"><div id="Index"> <div class="index-label">Index 🔎︎ </div> <div id="Bookmarks"> <input id="search-bar" type="text" class="search" placeholder="Search in chosen module"><nav class="index"></nav> </div> </div></aside><div id="DisplayArea" itemprop="articleBody"> <a name="bm_id3145068"></a><meta itemprop="keywords" content="formats, text as numbers"> <meta itemprop="keywords" content="time format conversion"> <meta itemprop="keywords" content="date formats,conversion"> <meta itemprop="keywords" content="converting,text, into numbers"> <h1 id="hd_id0908200901265171"> <a name="numbers_text"></a>Converting Text to Numbers </h1> <a name="text"></a> <p id="par_id0908200901265127" class="paragraph">Defaults settings in Calc converts text inside cells to the respective numeric values if an unambiguous conversion is possible. If no conversion is possible, Calc returns a #VALUE! error.</p> <p id="par_id0908200901265196" class="paragraph"><span class="emph">Only integer numbers including exponent are converted</span>, and ISO 8601 dates and times in their extended formats with separators. Anything else, like fractional numbers with decimal separators or dates other than ISO 8601, is not converted, as the text string would be locale dependent. Leading and trailing blanks are ignored.</p> <p id="par_id0908200901265220" class="paragraph">The following ISO 8601 formats are converted:</p> <ul> <li> <p id="par_id0908200901265288" class="paragraph">CCYY-MM-DD</p> </li> <li> <p id="par_id0908200901265267" class="paragraph">CCYY-MM-DDThh:mm</p> </li> <li> <p id="par_id0908200901265248" class="paragraph">CCYY-MM-DDThh:mm:ss</p> </li> <li> <p id="par_id0908200901265374" class="paragraph">CCYY-MM-DDThh:mm:ss,s</p> </li> <li> <p id="par_id0908200901265327" class="paragraph">CCYY-MM-DDThh:mm:ss.s</p> </li> <li> <p id="par_id0908200901265399" class="paragraph">hh:mm</p> </li> <li> <p id="par_id0908200901265347" class="paragraph">hh:mm:ss</p> </li> <li> <p id="par_id0908200901265349" class="paragraph">hh:mm:ss,s</p> </li> <li> <p id="par_id0908200901265342" class="paragraph">hh:mm:ss.s</p> </li> </ul> <p id="par_id0908200901265491" class="paragraph">The century code CC may not be omitted. Instead of the T date and time separator, exactly one space character may be used.</p> <p id="par_id0908200901265467" class="paragraph">If a date is given, it must be a valid Gregorian calendar date. In this case the optional time must be in the range 00:00 to 23:59:59.99999...</p> <p id="par_id0908200901265420" class="paragraph">If only a time string is given, it may have an hours value of more than 24, while minutes and seconds can have a maximum value of 59.</p> <div class="note"> <div class="noteicon"><img src="media/icon-themes/res/helpimg/note.svg" alt="note" title="note" style="width:40px;height:40px;"></div> <div class="notetext"><p id="par_id761567607207916">The conversion is done for single scalar values only, not within ranges.</p></div> </div> <br> <p id="par_id0908200901265448" class="paragraph">The conversion is done for single scalar values, as in =A1+A2, or ="1E2"+1. Cell range arguments are not affected, so SUM(A1:A2) differs from A1+A2 if at least one of the two cells contain a convertible string.</p> <p id="par_id090820090126540" class="paragraph">Strings inside formulas are also converted, such as in ="1999-11-22"+42, which returns the date 42 days after November 22nd, 1999. Calculations involving localized dates as strings inside the formula return an error. For example, the localized date string "11/22/1999" or "22.11.1999" cannot be used for the automatic conversion.</p> <div class="embedded"> <a name="regexnumex"></a> <div class="warning"> <div class="noteicon"><img src="media/icon-themes/res/helpimg/warning.svg" alt="warning" title="warning" style="width:40px;height:40px;"></div> <div class="notetext"><p id="par_id651572973288601">When using functions where one or more arguments are search criteria strings that represents a regular expression, the first attempt is to convert the string criteria to numbers. For example, ".0" will convert to 0.0 and so on. If successful, the match will not be a regular expression match but a numeric match. However, when switching to a locale where the decimal separator is not the dot makes the regular expression conversion work. To force the evaluation of the regular expression instead of a numeric expression, use some expression that can not be misread as numeric, such as ".[0]" or ".\0" or "(?i).0". </p></div> </div> <br> </div> <h2 id="hd_id1005200903485368">Example</h2> <p id="par_id1005200903485359" class="paragraph">In A1 enter the text <span class="literal">'1e2</span> (which is converted to the number 100 internally).</p> <p id="par_id1005200903485341" class="paragraph">In A2 enter <span class="literal">=A1+1</span> (which correctly results in 101).</p> <p id="par_id891567607263849" class="paragraph">The formula <span class="literal">=SUM(A1:A2)</span>, returns 101 instead of 201 because the conversion does not occur in a range, only for single scalar values. Here, '1e2 is treated as string which has value 0 for the SUM function.</p> <p id="par_id611567607779380" class="paragraph"><span class="literal">=SUM("1E2";1)</span> returns #VALUE! because SUM() and some others that iterate over number sequences explicitly check the argument type.</p> <h2 id="hd_id871567772424915">Changing the default text to number conversion settings</h2> <p id="par_id111567772433803" class="paragraph">The text to number conversion can be customized in the <a name="detailed_heading"></a><a target="_top" href="en-US/text/shared/optionen/detailedcalculation.html">Detailed Calculation Settings</a> option.</p> <a name="relatedtopics"></a><div class="relatedtopics"> <p class="related" itemprop="mentions"><a name="related"></a><span class="emph">Related Topics</span> </p> <div class="relatedbody" itemprop="mentions"> <div class="embedded"><p class="embedded"><a name="detailed_heading"></a><a target="_top" href="en-US/text/shared/optionen/detailedcalculation.html">Detailed Calculation Settings</a></p></div> <div class="embedded"><p class="embedded"><a name="text_numbers"></a><a target="_top" href="en-US/text/scalc/guide/text_numbers.html">Formatting Numbers as Text</a> </p></div> <div class="embedded"><p class="embedded"><a name="integer_leading_zero"></a><a target="_top" href="en-US/text/scalc/guide/integer_leading_zero.html">Entering a Number with Leading Zeros</a></p></div> <p id="par_id0908200901265544" class="paragraph"><a target="_top" href="en-US/text/shared/01/05020300.html">Format - Cells - Numbers</a></p> <div class="embedded"><p class="embedded"><a name="format_value"></a><a target="_top" href="en-US/text/scalc/guide/format_value.html">Formatting Numbers With Decimals</a> </p></div> </div> </div> </div> <div class="search-frame"></div> <div class="donation-frame"></div> <footer><div id="DEBUG" class="debug"> <h3 class="bug">Help content debug info:</h3> <p>This page is: <a href="https://opengrok.libreoffice.org/xref/help/source/text/scalc/guide/numbers_text.xhp" target="_blank">/text/scalc/guide/numbers_text.xhp</a></p> <p>Title is: Converting Text to Numbers</p> <p id="bm_module"></p> <p id="bm_system"></p> <p id="bm_HID"></p> </div></footer> </body> </html>
Name | Type | Size | Permission | Actions |
---|---|---|---|---|
address_auto.html | File | 6.34 KB | 0644 |
|
auto_off.html | File | 6.82 KB | 0644 |
|
autofilter.html | File | 6.93 KB | 0644 |
|
autoformat.html | File | 5.89 KB | 0644 |
|
background.html | File | 5.48 KB | 0644 |
|
borders.html | File | 13.91 KB | 0644 |
|
calc_date.html | File | 5.68 KB | 0644 |
|
calc_series.html | File | 7.9 KB | 0644 |
|
calc_timevalues.html | File | 3.88 KB | 0644 |
|
calculate.html | File | 4.83 KB | 0644 |
|
cell_enter.html | File | 5.78 KB | 0644 |
|
cell_protect.html | File | 8.4 KB | 0644 |
|
cell_unprotect.html | File | 4.05 KB | 0644 |
|
cellcopy.html | File | 6 KB | 0644 |
|
cellreference_dragdrop.html | File | 5.55 KB | 0644 |
|
cellreferences.html | File | 7.89 KB | 0644 |
|
cellreferences_url.html | File | 5.8 KB | 0644 |
|
cellstyle_by_formula.html | File | 5.69 KB | 0644 |
|
cellstyle_conditional.html | File | 11.13 KB | 0644 |
|
cellstyle_minusvalue.html | File | 4.84 KB | 0644 |
|
consolidate.html | File | 7.86 KB | 0644 |
|
csv_files.html | File | 8.52 KB | 0644 |
|
csv_formula.html | File | 7.83 KB | 0644 |
|
currency_format.html | File | 6.4 KB | 0644 |
|
database_define.html | File | 5.14 KB | 0644 |
|
database_filter.html | File | 6.94 KB | 0644 |
|
database_sort.html | File | 4.46 KB | 0644 |
|
datapilot.html | File | 4.93 KB | 0644 |
|
datapilot_createtable.html | File | 7.93 KB | 0644 |
|
datapilot_deletetable.html | File | 5 KB | 0644 |
|
datapilot_edittable.html | File | 6.43 KB | 0644 |
|
datapilot_filtertable.html | File | 7.52 KB | 0644 |
|
datapilot_grouping.html | File | 5.42 KB | 0644 |
|
datapilot_tipps.html | File | 5.58 KB | 0644 |
|
datapilot_updatetable.html | File | 4.96 KB | 0644 |
|
dbase_files.html | File | 7.72 KB | 0644 |
|
design.html | File | 6 KB | 0644 |
|
edit_multitables.html | File | 4.92 KB | 0644 |
|
filters.html | File | 5.96 KB | 0644 |
|
finding.html | File | 7.59 KB | 0644 |
|
format_table.html | File | 6.51 KB | 0644 |
|
format_value.html | File | 6.08 KB | 0644 |
|
format_value_userdef.html | File | 7.56 KB | 0644 |
|
formula_copy.html | File | 5.33 KB | 0644 |
|
formula_enter.html | File | 6.79 KB | 0644 |
|
formula_value.html | File | 4.36 KB | 0644 |
|
formulas.html | File | 6.45 KB | 0644 |
|
fraction_enter.html | File | 4.39 KB | 0644 |
|
goalseek.html | File | 6.14 KB | 0644 |
|
html_doc.html | File | 5.91 KB | 0644 |
|
integer_leading_zero.html | File | 6.08 KB | 0644 |
|
keyboard.html | File | 7.85 KB | 0644 |
|
line_fix.html | File | 5.72 KB | 0644 |
|
main.html | File | 22.58 KB | 0644 |
|
mark_cells.html | File | 6.82 KB | 0644 |
|
matrixformula.html | File | 4.72 KB | 0644 |
|
move_dragdrop.html | File | 9.4 KB | 0644 |
|
multi_tables.html | File | 4.51 KB | 0644 |
|
multioperation.html | File | 9.26 KB | 0644 |
|
multitables.html | File | 5.97 KB | 0644 |
|
note_insert.html | File | 5.34 KB | 0644 |
|
numbers_text.html | File | 9.54 KB | 0644 |
|
pivotchart.html | File | 4.91 KB | 0644 |
|
pivotchart_create.html | File | 5.76 KB | 0644 |
|
pivotchart_delete.html | File | 4.77 KB | 0644 |
|
pivotchart_edit.html | File | 7.79 KB | 0644 |
|
pivotchart_filter.html | File | 5.41 KB | 0644 |
|
pivotchart_update.html | File | 4.56 KB | 0644 |
|
print_details.html | File | 5.24 KB | 0644 |
|
print_exact.html | File | 4.84 KB | 0644 |
|
print_landscape.html | File | 6.95 KB | 0644 |
|
print_title_row.html | File | 6.4 KB | 0644 |
|
printranges.html | File | 7.71 KB | 0644 |
|
relativ_absolut_ref.html | File | 7.76 KB | 0644 |
|
rename_table.html | File | 7.49 KB | 0644 |
|
rounding_numbers.html | File | 5.81 KB | 0644 |
|
row_height.html | File | 5.25 KB | 0644 |
|
scenario.html | File | 6.81 KB | 0644 |
|
sorted_list.html | File | 5.1 KB | 0644 |
|
specialfilter.html | File | 11.25 KB | 0644 |
|
super_subscript.html | File | 4.19 KB | 0644 |
|
table_cellmerge.html | File | 4.88 KB | 0644 |
|
table_rotate.html | File | 4.28 KB | 0644 |
|
table_view.html | File | 4.65 KB | 0644 |
|
text_numbers.html | File | 5.23 KB | 0644 |
|
text_rotate.html | File | 4.05 KB | 0644 |
|
text_wrap.html | File | 4.12 KB | 0644 |
|
userdefined_function.html | File | 8.33 KB | 0644 |
|
validity.html | File | 7.79 KB | 0644 |
|
value_with_name.html | File | 7.99 KB | 0644 |
|
webquery.html | File | 7.11 KB | 0644 |
|
year2000.html | File | 4.12 KB | 0644 |
|