{"id":31672,"date":"2018-04-21T15:47:50","date_gmt":"2018-04-21T15:47:50","guid":{"rendered":"https:\/\/ampscript.guide\/formatnumber\/"},"modified":"2021-04-06T00:58:54","modified_gmt":"2021-04-06T00:58:54","slug":"formatnumber","status":"publish","type":"post","link":"https:\/\/ampscript.guide\/formatnumber\/","title":{"rendered":"FormatNumber"},"content":{"rendered":"<h2>FormatNumber<\/h2>\n<p>This function formats a string as a number.<\/p>\n<p>Format patterns follow the C# format types outlined in the official Microsoft documentation:<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/base-types\/standard-numeric-format-strings\">Standard Numeric Format Strings<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/base-types\/standard-date-and-time-format-strings\">Standard Date and Time Format Strings<\/a><\/li>\n<\/ul>\n<p>Some of these custom formats are supported:<\/p>\n<ul>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/base-types\/custom-numeric-format-strings\">Custom Numeric Format Strings<\/a><\/li>\n<li><a href=\"https:\/\/docs.microsoft.com\/en-us\/dotnet\/standard\/base-types\/custom-date-and-time-format-strings\">Custom Date and Time Format Strings<\/a><\/li>\n<\/ul>\n<h3>Arguments<\/h3>\n<p><code>FormatNumber(1,2,3)<\/code><\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: center\">Ordinal<\/th>\n<th style=\"text-align: left\">Type<\/th>\n<th style=\"text-align: left\">Required<\/th>\n<th style=\"text-align: left\">Description<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: center\">1<\/td>\n<td style=\"text-align: left\">String<\/td>\n<td style=\"text-align: left\">True<\/td>\n<td style=\"text-align: left\">The number string to format<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">2<\/td>\n<td style=\"text-align: left\">String<\/td>\n<td style=\"text-align: left\">True<\/td>\n<td style=\"text-align: left\">The output format pattern (see table below for values)<\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: center\">3<\/td>\n<td style=\"text-align: left\">String<\/td>\n<td style=\"text-align: left\">False<\/td>\n<td style=\"text-align: left\">ISO code for locale-specific pattern elements<\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote>\n<p>NOTE: By default, this function rounds half up to two decimal places.<\/p>\n<\/blockquote>\n<p>Here are a few examples of format patterns, given a number of <code>123<\/code>:<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left\">Element<\/th>\n<th style=\"text-align: left\">Format Pattern<\/th>\n<th style=\"text-align: left\">Output<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left\">Currency<\/td>\n<td style=\"text-align: left\"><code>C<\/code> or <code>c<\/code><\/td>\n<td style=\"text-align: left\"><code>$123.00<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Decimal<\/td>\n<td style=\"text-align: left\"><code>D<\/code> or <code>d<\/code><\/td>\n<td style=\"text-align: left\"><code>123<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Exponential (scientific)<\/td>\n<td style=\"text-align: left\"><code>E<\/code> or <code>e<\/code><\/td>\n<td style=\"text-align: left\"><code>1.230000E+002<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Fixed-point<\/td>\n<td style=\"text-align: left\"><code>F<\/code> of <code>f<\/code><\/td>\n<td style=\"text-align: left\"><code>123.00<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">General<\/td>\n<td style=\"text-align: left\"><code>G<\/code> or <code>g<\/code><\/td>\n<td style=\"text-align: left\"><code>123<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Number<\/td>\n<td style=\"text-align: left\"><code>N<\/code> or <code>n<\/code><\/td>\n<td style=\"text-align: left\"><code>123.00<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Percent<\/td>\n<td style=\"text-align: left\"><code>P<\/code> or <code>p<\/code><\/td>\n<td style=\"text-align: left\"><code>12,300.00 %<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Hexadecimal<\/td>\n<td style=\"text-align: left\"><code>X<\/code> or <code>x<\/code><\/td>\n<td style=\"text-align: left\"><code>7B<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<blockquote>\n<p>NOTE: The <code>D<\/code> pattern requires an integer for input.<\/p>\n<\/blockquote>\n<p>Here are a few examples of custom format patterns, given a number of <code>-1.8967<\/code>:<\/p>\n<table>\n<thead>\n<tr>\n<th style=\"text-align: left\">Element<\/th>\n<th style=\"text-align: left\">Format Pattern<\/th>\n<th style=\"text-align: left\">Example<\/th>\n<th style=\"text-align: left\">Output<\/th>\n<\/tr>\n<\/thead>\n<tbody>\n<tr>\n<td style=\"text-align: left\">Zero placeholder<\/td>\n<td style=\"text-align: left\"><code>0<\/code><\/td>\n<td style=\"text-align: left\"><code>\"0000\"<\/code><\/td>\n<td style=\"text-align: left\"><code>-0002<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Digit placeholder<\/td>\n<td style=\"text-align: left\"><code>#<\/code><\/td>\n<td style=\"text-align: left\"><code>\"###0\"<\/code><\/td>\n<td style=\"text-align: left\"><code>-2<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Decimal point<\/td>\n<td style=\"text-align: left\"><code>.<\/code><\/td>\n<td style=\"text-align: left\"><code>\"#0.00\"<\/code><\/td>\n<td style=\"text-align: left\"><code>-1.90<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Group separator and scaling<\/td>\n<td style=\"text-align: left\"><code>,<\/code><\/td>\n<td style=\"text-align: left\"><code>\"0,00#.##\"<\/code><\/td>\n<td style=\"text-align: left\"><code>-0,001.9<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Percentage placeholder<\/td>\n<td style=\"text-align: left\"><code>%<\/code><\/td>\n<td style=\"text-align: left\"><code>\"#.00%\"<\/code><\/td>\n<td style=\"text-align: left\"><code>-189.67%<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Exponential notation<\/td>\n<td style=\"text-align: left\"><code>E0<\/code>, <code>E+0<\/code>, <code>e0<\/code> or <code>e+0<\/code><\/td>\n<td style=\"text-align: left\"><code>\"#0.0e0\"<\/code><\/td>\n<td style=\"text-align: left\"><code>-19.0e-1<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Escape character<\/td>\n<td style=\"text-align: left\"><code>\\<\/code><\/td>\n<td style=\"text-align: left\"><code>\"\\###0.000\\#\"<\/code><\/td>\n<td style=\"text-align: left\"><code>-#1.897#<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Literal string delimiter<\/td>\n<td style=\"text-align: left\"><code>'string'<\/code> or <code>\"string\"<\/code><\/td>\n<td style=\"text-align: left\"><code>\"#.##' points'\"<\/code><\/td>\n<td style=\"text-align: left\"><code>-1.9 points<\/code><\/td>\n<\/tr>\n<tr>\n<td style=\"text-align: left\">Section separator<\/td>\n<td style=\"text-align: left\"><code>;<\/code><\/td>\n<td style=\"text-align: left\"><code>\"#0.00;(#0.00)\"<\/code><\/td>\n<td style=\"text-align: left\"><code>(1.90)<\/code><\/td>\n<\/tr>\n<\/tbody>\n<\/table>\n<h3>Example 1<\/h3>\n<pre><code>%%[\n\nvar @num\nvar @Currency\nvar @Currency3\nvar @Decimal\nvar @Exponential\nvar @Fixed\nvar @Fixed3\nvar @General\nvar @Number\nvar @Number3\nvar @Percent\nvar @Hex\n\nset @num = \"123\"\n\nset @Currency = FormatNumber(@num, \"C\")\nset @Currency3 = FormatNumber(@num, \"C3\")\nset @Decimal = FormatNumber(@num, \"D\")\nset @Exponential = FormatNumber(@num, \"E\")\nset @Fixed = FormatNumber(@num, \"F\")\nset @Fixed3 = FormatNumber(@num, \"F3\")\nset @General = FormatNumber(@num, \"G\")\nset @Number = FormatNumber(@num, \"N\")\nset @Number3 = FormatNumber(@num, \"N3\")\nset @Percent = FormatNumber(@num, \"P\")\nset @Hex = FormatNumber(@num, \"X\")\n\n]%%\nnum: %%=v(@num)=%%\n&lt;br&gt;&lt;br&gt;Currency: %%=v(@Currency)=%%\n&lt;br&gt;Currency3: %%=v(@Currency3)=%%\n&lt;br&gt;Decimal: %%=v(@Decimal)=%%\n&lt;br&gt;Exponential: %%=v(@Exponential)=%%\n&lt;br&gt;Fixed: %%=v(@Fixed)=%%\n&lt;br&gt;Fixed3: %%=v(@Fixed3)=%%\n&lt;br&gt;General: %%=v(@General)=%%\n&lt;br&gt;Number: %%=v(@Number)=%%\n&lt;br&gt;Number3: %%=v(@Number3)=%%\n&lt;br&gt;Percent: %%=v(@Percent)=%%\n&lt;br&gt;Hex: %%=v(@Hex)=%%<\/code><\/pre>\n<h4>Output<\/h4>\n<pre><code>num: 123\n\nCurrency: $123.00\nCurrency3: $123.000\nDecimal: 123\nExponential: 1.230000E+002\nFixed: 123.00\nFixed3: 123.000\nGeneral: 123\nNumber: 123.00\nNumber3: 123.000\nPercent: 12,300.00 %\nHex: 7B<\/code><\/pre>\n<h3>Example 2<\/h3>\n<div class=\"rcp_restricted rcp_paid_only\"><div>\n\n\n\t\n\t<form id=\"rcp_login_form\"  class=\"rcp_form\" method=\"POST\" action=\"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31672\/\">\n\n\t\t\n\t\t<fieldset class=\"rcp_login_data\">\n\t\t\t<p>\n\t\t\t\t<label for=\"rcp_user_login\">Username or Email<\/label>\n\t\t\t\t<input name=\"rcp_user_login\" id=\"rcp_user_login\" class=\"required\" type=\"text\"\/>\n\t\t\t<\/p>\n\t\t\t<p>\n\t\t\t\t<label for=\"rcp_user_pass\">Password<\/label>\n\t\t\t\t<input name=\"rcp_user_pass\" id=\"rcp_user_pass\" class=\"required\" type=\"password\"\/>\n\t\t\t<\/p>\n\t\t\t\t\t\t<p>\n\t\t\t\t<input type=\"checkbox\" name=\"rcp_user_remember\" id=\"rcp_user_remember\" value=\"1\"\/>\n\t\t\t\t<label for=\"rcp_user_remember\">Remember me<\/label>\n\t\t\t<\/p>\n\t\t\t<p class=\"rcp_lost_password\"><a href=\"\/wp-json\/wp\/v2\/posts\/31672?rcp_action=lostpassword\">Lost your password?<\/a><\/p>\n\t\t\t<p>\n\t\t\t\t<input type=\"hidden\" name=\"rcp_action\" value=\"login\"\/>\n\t\t\t\t<input type=\"hidden\" name=\"rcp_redirect\" value=\"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31672\/\"\/>\n\t\t\t\t<input type=\"hidden\" name=\"rcp_login_nonce\" value=\"3677078318\"\/>\n\t\t\t\t<input id=\"rcp_login_submit\" class=\"rcp-button\" type=\"submit\" value=\"Login\"\/>\n\t\t\t<\/p>\n\t\t\t\t\t<\/fieldset>\n\n\t\t\n\t<\/form>\n<br \/>\nNot a subscriber? <a href=\"\/subscriptions\/subscribe\/\">Subscribe now<\/a>.\n<\/div>\n<\/div>\n<h3>Example 3<\/h3>\n<div class=\"rcp_restricted rcp_paid_only\"><div>\n\n\n\t\n\t<form id=\"rcp_login_form\"  class=\"rcp_form\" method=\"POST\" action=\"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31672\/\">\n\n\t\t\n\t\t<fieldset class=\"rcp_login_data\">\n\t\t\t<p>\n\t\t\t\t<label for=\"rcp_user_login\">Username or Email<\/label>\n\t\t\t\t<input name=\"rcp_user_login\" id=\"rcp_user_login\" class=\"required\" type=\"text\"\/>\n\t\t\t<\/p>\n\t\t\t<p>\n\t\t\t\t<label for=\"rcp_user_pass\">Password<\/label>\n\t\t\t\t<input name=\"rcp_user_pass\" id=\"rcp_user_pass\" class=\"required\" type=\"password\"\/>\n\t\t\t<\/p>\n\t\t\t\t\t\t<p>\n\t\t\t\t<input type=\"checkbox\" name=\"rcp_user_remember\" id=\"rcp_user_remember\" value=\"1\"\/>\n\t\t\t\t<label for=\"rcp_user_remember\">Remember me<\/label>\n\t\t\t<\/p>\n\t\t\t<p class=\"rcp_lost_password\"><a href=\"\/wp-json\/wp\/v2\/posts\/31672?rcp_action=lostpassword\">Lost your password?<\/a><\/p>\n\t\t\t<p>\n\t\t\t\t<input type=\"hidden\" name=\"rcp_action\" value=\"login\"\/>\n\t\t\t\t<input type=\"hidden\" name=\"rcp_redirect\" value=\"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31672\/\"\/>\n\t\t\t\t<input type=\"hidden\" name=\"rcp_login_nonce\" value=\"3677078318\"\/>\n\t\t\t\t<input id=\"rcp_login_submit\" class=\"rcp-button\" type=\"submit\" value=\"Login\"\/>\n\t\t\t<\/p>\n\t\t\t\t\t<\/fieldset>\n\n\t\t\n\t<\/form>\n<br \/>\nNot a subscriber? <a href=\"\/subscriptions\/subscribe\/\">Subscribe now<\/a>.\n<\/div>\n<\/div>\n","protected":false},"excerpt":{"rendered":"<p>FormatNumber This function formats a string as a number. Format patterns follow the C# format types outlined in the official Microsoft documentation: Standard Numeric Format Strings Standard Date and Time Format Strings Some of these custom formats are supported: Custom Numeric Format Strings Custom Date and Time Format Strings Arguments FormatNumber(1,2,3) Ordinal Type Required Description [&hellip;]<\/p>\n","protected":false},"author":1,"featured_media":0,"comment_status":"closed","ping_status":"closed","sticky":false,"template":"","format":"standard","meta":[],"categories":[1],"tags":[],"yoast_head":"<!-- This site is optimized with the Yoast SEO Premium plugin v14.7 - https:\/\/yoast.com\/wordpress\/plugins\/seo\/ -->\n<title>The AMPscript Guide - FormatNumber<\/title>\n<meta name=\"robots\" content=\"index, follow\" \/>\n<meta name=\"googlebot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<meta name=\"bingbot\" content=\"index, follow, max-snippet:-1, max-image-preview:large, max-video-preview:-1\" \/>\n<link rel=\"canonical\" href=\"https:\/\/ampscript.guide\/formatnumber\/\" \/>\n<meta property=\"og:locale\" content=\"en_US\" \/>\n<meta property=\"og:type\" content=\"article\" \/>\n<meta property=\"og:title\" content=\"The AMPscript Guide - FormatNumber\" \/>\n<meta property=\"og:description\" content=\"FormatNumber This function formats a string as a number. Format patterns follow the C# format types outlined in the official Microsoft documentation: Standard Numeric Format Strings Standard Date and Time Format Strings Some of these custom formats are supported: Custom Numeric Format Strings Custom Date and Time Format Strings Arguments FormatNumber(1,2,3) Ordinal Type Required Description [&hellip;]\" \/>\n<meta property=\"og:url\" content=\"https:\/\/ampscript.guide\/formatnumber\/\" \/>\n<meta property=\"og:site_name\" content=\"The AMPscript Guide\" \/>\n<meta property=\"article:published_time\" content=\"2018-04-21T15:47:50+00:00\" \/>\n<meta property=\"article:modified_time\" content=\"2021-04-06T00:58:54+00:00\" \/>\n<meta name=\"twitter:card\" content=\"summary_large_image\" \/>\n<script type=\"application\/ld+json\" class=\"yoast-schema-graph\">{\"@context\":\"https:\/\/schema.org\",\"@graph\":[{\"@type\":\"WebSite\",\"@id\":\"https:\/\/ampscript.guide\/#website\",\"url\":\"https:\/\/ampscript.guide\/\",\"name\":\"The AMPscript Guide\",\"description\":\"The Definitive Scripting Manual for Salesforce Marketing Cloud\",\"potentialAction\":[{\"@type\":\"SearchAction\",\"target\":\"https:\/\/ampscript.guide\/?s={search_term_string}\",\"query-input\":\"required name=search_term_string\"}],\"inLanguage\":\"en-US\"},{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/formatnumber\/#webpage\",\"url\":\"https:\/\/ampscript.guide\/formatnumber\/\",\"name\":\"The AMPscript Guide - FormatNumber\",\"isPartOf\":{\"@id\":\"https:\/\/ampscript.guide\/#website\"},\"datePublished\":\"2018-04-21T15:47:50+00:00\",\"dateModified\":\"2021-04-06T00:58:54+00:00\",\"author\":{\"@id\":\"https:\/\/ampscript.guide\/#\/schema\/person\/5335042f77731e84f9808aecef25daec\"},\"breadcrumb\":{\"@id\":\"https:\/\/ampscript.guide\/formatnumber\/#breadcrumb\"},\"inLanguage\":\"en-US\",\"potentialAction\":[{\"@type\":\"ReadAction\",\"target\":[\"https:\/\/ampscript.guide\/formatnumber\/\"]}]},{\"@type\":\"BreadcrumbList\",\"@id\":\"https:\/\/ampscript.guide\/formatnumber\/#breadcrumb\",\"itemListElement\":[{\"@type\":\"ListItem\",\"position\":1,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/\",\"url\":\"https:\/\/ampscript.guide\/\",\"name\":\"Home\"}},{\"@type\":\"ListItem\",\"position\":2,\"item\":{\"@type\":\"WebPage\",\"@id\":\"https:\/\/ampscript.guide\/formatnumber\/\",\"url\":\"https:\/\/ampscript.guide\/formatnumber\/\",\"name\":\"FormatNumber\"}}]},{\"@type\":[\"Person\"],\"@id\":\"https:\/\/ampscript.guide\/#\/schema\/person\/5335042f77731e84f9808aecef25daec\",\"name\":\"dev\"}]}<\/script>\n<!-- \/ Yoast SEO Premium plugin. -->","_links":{"self":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31672"}],"collection":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts"}],"about":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/types\/post"}],"author":[{"embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/users\/1"}],"replies":[{"embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/comments?post=31672"}],"version-history":[{"count":0,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/posts\/31672\/revisions"}],"wp:attachment":[{"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/media?parent=31672"}],"wp:term":[{"taxonomy":"category","embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/categories?post=31672"},{"taxonomy":"post_tag","embeddable":true,"href":"https:\/\/ampscript.guide\/wp-json\/wp\/v2\/tags?post=31672"}],"curies":[{"name":"wp","href":"https:\/\/api.w.org\/{rel}","templated":true}]}}