# Using Variables in Formulas

After you add a variable, you can use it in formulas for various system objects (columns, tables, views, etc.). It is important to remember that all variable values are treated by the system as a simple text. Therefore you cannot simply input variables into formulas that deal with numbers or dates.

When creating formulas with a variable, you will need to convert the variable into a corresponding format. Variables are inserted into formulas in square brackets (for example, [hourly rate]). To covert a variable into the necessary format, use the Type Conversion functions ToXXX([variable]), for example:

- ToNumber( ) used to convert a variable to the number format (for example, ToNumber([hourly rate]));

- ToDate( ) used to convert a variable to the date format (for example, ToDate([beginning date]));

- ToTimeOfDay( ) function used to convert a variable to the day time format (for example, ToTimeOfDay([day time])).

When you create a formula, there may occur a situation when a variable and a column have the same name. References to column values and variables are given in formulas in the same way – in square brackets (for example, [project start date]). If the names of the column and the variable coincide, the formula will use the column value.

The following table contains examples of converting variables into a different format and using variables in formulas:

Variable Name |
Value |
Format to Convert to |
Conversion Function |
Formula Example, Description |

hourly rate |
15.00 |
Numeric |
ToNumber( [hourly rate]) |
ToNumber( [hourly rate]*8 The formula calculates the amount earned per 8 hours of a normal workday. |

start date |
01-01-2006 |
Date |
ToDate( [start date]) |
Today () - ToDate( [start date]) The formula calculates how many days have passed from the project start date. |

**Next: **Working with Formulas