Menu

format()

Updated: 2025-03-25

The format() function is commonly used in templates to format numbers, dates and other information. It is the first function to reach for when you need to display data in the correct format. Simply applying the format() function without specifying additional parameters can quickly change the output.

The format() function respects regional settings and will display currency and dates in the language of the template. 

Currency

Apply format() to any numerical field code to display it as currency. 

  • TaxCycle does not add the number sign before currency. If you want the number sign in your template, add it in the plain text next to the field code.
  • If you are creating a formula by adding or subtracting field codes, add the format() around the full formula to display the result as currency.
  • To change the decimals, round to the place value using "C0" for no decimals, "C" or "C2" for two decimals. This will round the number up or down. See also round() and abs().
Code Result
{{CurrentClient.T1.RefundBalanceOwing.BalanceOwing}} 1254.9
{{format(CurrentClient.T1.RefundBalanceOwing.BalanceOwing)}} 1,254.90
${{format(CurrentClient.T1.RefundBalanceOwing.BalanceOwing)}} $1,254.90
${{format(CurrentClient.T1.RefundBalanceOwing.BalanceOwing, "C0")}} $1,255
${{format(sum(CurrentClient.BillingWorksheet.Totals.TotalBeforeTaxes, CurrentSpouse.BillingWorksheet.Totals.TotalBeforeTaxes))}} $300.00

Dates

By default, TaxCycle displays the full date and time for any date field. Apply format() and related parameters to adjust the display of the date.

  • After the field code, add a comma, then the date of "January 2, 2003" to indicate the format you prefer.
  • You can also use traditional date format masks. See the table on the Microsoft Custom Date and Time Format Strings page for a list of supported format strings.
Code Result
{{CurrentClient.Info.CommonData.FileByDate}} 2025-04-30 12:00:00 AM
{{format(CurrentClient.Info.CommonData.FileByDate, "January 2, 2003")}} April 30, 2025
{{format(CurrentClient.Info.CommonData.FileByDate, "Jan 2, 2003")}} Apr 30, 2025
{{format(CurrentClient.Info.CommonData.FileByDate, "2003-01-02")}} 2025-04-30
{{format(CurrentClient.Info.CommonData.FileByDate, "03-01-02")}} 19-04-30
{{format(CurrentClient.Info.CommonData.FileByDate, "03-Jan-02")}} 19-Apr-30
{{format(CurrentClient.Info.CommonData.FileByDate, "yy-MMM-dd")}} 19-Apr-30
{{format(CurrentClient.Info.CommonData.FileByDate, "January 2, 2003 at 4:05")}} April 30, 2025 at 1:22
{{format(CurrentClient.Info.CommonData.FileByDate, "January 2, 2003 at 16:05")}} April 30, 2025 at 13:22
{{format(CurrentClient.Info.CommonData.FileByDate, "yyyy-dd-MMM")}} 2025-04-30

Phone number

Apply format() to add the parentheses and dash to a phone number field.

Code Result
{{CurrentClient.Info.Address.HomePhone}} 555555555
{{format(CurrentClient.Info.Address.HomePhone)}} (555) 555-5555

Postal code

Apply format() to add the space to a postal code field.

Code Result
{{CurrentClient.Info.Address.PostalCode}} H0H0H0
{{format(CurrentClient.Info.Address.PostalCode)}} H0H 0H0

Social Insurance and Business Numbers

Apply format() add spaces to a social insurance number. Add Field to the end of a business number to display the account type. This can be combined with the mask() function.

Code Result
{{CurrentClient.Info.ID.SIN}} 111111118
{{format(CurrentClient.Info.ID.SIN)}} 111 111 118
{{CurrentClient.Info.ID.BusinessNumber}} 8510871480001
{{format(CurrentClient.Info.ID.BusinessNumberField)}} 851087148 RC0001

Text 

Apply format() and the "text" parameter to display the text version of a dropdown field. See also abbreviate() and Example: T3 Trust Type Dropdown Fields in Templates.

Code Result
{{CurrentClient.Info.Residency.ProvinceDec31}} NewBrunswick
{{format(CurrentClient.Info.Residency.ProvinceDec31Field,"text")}} New Brunswick
{{CurrentClient.Info.ID.Type}} TestamentarySpousal
{{format(CurrentClient.Info.ID.TypeField,"text")}} Testamentary - Spousal or Common-law partner

Code

Apply format() and the "code" parameter to display the code from dropdown field. See also Example: T3 Trust Type Dropdown Fields in Templates.

Code Result
{{CurrentClient.Info.ID.Type}} TestamentarySpousal
{{format(CurrentClient.Info.ID.TypeField,"code")}} 905