# Elements of ColdFusion Expressions

The following objects can be used to build expressions:

Objects Used to Build ColdFusion Expressions
Type | Description
--- | ---
Integers | Numbers with no decimal point.
Real numbers | Numbers with a decimal part. Also known as floating point numbers. The range of ColdFusion numbers is approximately ±10300, or ±1 with 300 zeros after it. Most operations are accurate to 12 digits after the decimal point. ColdFusion supports scientific notation.
Strings | Text values, which can be enclosed in single (') or double (") quotes. Strings length is limited only by the amount of available memory on the ColdFusion server. To use a single quote inside a string that is single quoted, escape the single quote by using two single quotes. You can similarly escape a double quote inside a double quote-enclosed string. To insert a pound sign in a string, the pound sign must be escaped, or doubled,
Boolean values | The result of a logical operation. Their value can be either TRUE or FALSE. The numerical value of TRUE is 1. The numerical value of FALSE is 0. When converted to a string, TRUE becomes "YES" and FALSE becomes "NO".
Date values | Date-and-time values identify a date and time in the range 100AD to 9999AD. If no time part is specified, time is set to 12:00am. You can also directly enter a date object in any of the following formats:
    "October 30, 1999"
    "Oct 30, 1999"
    "Oct. 30, 1999"
    "10/30/99"
    "1999-30-10"
Time values | You can directly enter a date-and-time object in any of the following formats:
    "October 30, 1999 02:34:12"
    "October 30, 1999 2:34a"
    "October 30, 1999 2:34am"
    "October 30, 1999 02:34am"
    "October 30, 1999 2am"
The time part of the object is accurate to the second.
Lists | Lists are a special kind of string, made up of elements separated by delimiters. You specify the allowable delimiters for a list by [HOW?] A list can have more than one delimiting character. The default delimiting character, used by all list processing functions is a comma: ",". White space is not considered a delimiter. However, when using lists where elements may be separated by white space as well as other delimiters, be sure to add the white space characters to the delimiters. Delimiters before the first element and after the last element are ignored. The structure of lists is flat - that is, lists cannot be nested into one another. Also, lists can contain no "empty" elements. A list can be empty, however. The empty list is equivalent to the empty string "".
Structures | You can use structures to create and maintain key-value pairs, to refer to related string values as a unit rather than individually, or to create associative arrays. For more information about structures, see Developing Web Applications with ColdFusion.
Arrays | Arrays are tables of objects or data that can be indexed. Although the ArrayNew function only supports creating up to three-dimensional arrays, there is no limit on array size or maximum dimension. Elements stored in an array are referenced as follows: <CFSET myarray[1][2]=Now()> For more information about arrays, see Developing Web Applications with ColdFusion.
Queries | ColdFusion queries can be referenced as objects by assigning a query to a variable:
    <CFQUERY NAME=myquery
        DATASOURCE=mydata
        SELECT * FROM CUSTOMERS
    </CFQUERY>

    <CFSET myquery2=myquery>
In this case (unlike the same operation with arrays) the query is not copied. Instead, both names point to the record set data so that if you make changes to the table referenced in the query, the original query and the query object myquery2 will both reflect those changes. Queries and variables cannot have the same name at the same time in the same application page.
COM objects | COM (Component Object Model) objects are non-visual components that encapsulate specific functionality you can invoke in your application pages. ActiveX, OCX, CORBA, and ADO objects are examples of COM objects. COM objects generally contain methods, like functions, you can use to execute certain operations:
    <CFSET temp=Mailer.SendMail()>
COM objects also generally contain properties you can read and write using ColdFusion variables:
    <CFSET Mailer.FromName=Form.fromname>
Properties can be invoked on either side of an assignment. For more information about COM objects, see Developing Web Applications with ColdFusion.
Variables | When variables are used in ColdFusion expressions, the value stored in the variable is returned. The values can be one of the previously described basic objects: numbers, strings, Boolean values, date-and-time objects, or lists.

## Notes on date-and-time values

There are a variety of ways in which a date-and-time value can be entered in ColdFusion. You can use the functions that create date-and-time objects using various criteria. (See Chapter 2 for information about date-and-time functions.)

### 21st century dates

Two-digit years from 00 to 29 are treated as 21st century dates; 30 to 99 are treated as 20th century dates.

    "October 30, 2015"
    "October 30, 15"

Note | Internally to ColdFusion, date-and-time values are represented on a time line as a subset of the real numbers. This is done for efficiency in evaluation and because it directly mimics the method used by many popular database systems, including Microsoft Access. One day is equal to the difference between two successive integers. The time portion of the date-and-time value is stored in the fractional part of the real number.

Thus, arithmetic operations can be used to manipulate date-and-time values. For example, Now() + 1 will evaluate to tomorrow at the same time. However, we strongly discourage ColdFusion developers from using this potentially troublesome method of manipulating date-and-time objects. Date-and-time manipulation routines should be used instead.

### Fast date/time dates in UNIX

On UNIX, there is a switch that provides fast date-time parsing. If you have enabled this switch, you must refer to dates in expressions in the following order: month, day, and year. For example:

    <CFIF "11/23/1998" GT "11/15/1998">

If this switch is set, the default date format returned by the DateFormat() function cannot be parsed in an expression. However, if you specify a mask, indicating the correct order, such as, mm/dd/yyyy, the date returned by this function can be a parsed.

The Fast Date/Time Parsing switch is set on the ColdFusion Administrator Server Settings page. Refer to Administering ColdFusion Server for more information about ColdFusion settings.

Note | Complex objects, such as arrays, structures, queries, and COM objects are passed to custom tags surrounded by pound signs (#).

## Notes on using variables

Variable names must begin with a letter that can be followed by any number of letters, numbers, or the underscore character "_". For example, TheVariable_1 and TheVariable_2 are valid variable names, while 1stVariable and WhatAVariable! are not.

Sometimes variable names can begin with a qualifier that itself is a variable name. The qualifier name of a variable is separated from the qualified name with a period character (.). For example, Form.MyVariable is a valid qualified variable name. The qualifier, in this case "Form," signifies that we are interested in the form variable MyVariable, as opposed to, for example, the client variable MyVariable (Client.MyVariable). Qualifiers are also known as scopes. Thus MyVariable is said to belong to the Form scope.

In some cases, a variable must have pounds signs around it to allow ColdFusion to distinguish it from string or HTML text and to insert its value as opposed to its name. For more information on how to use pound signs in expressions see Pound Signs.

### Functions

Because ColdFusion functions return basic objects, such as numbers, strings, Boolean values, date-and-time objects, lists, arrays, structures, queries, and COM objects, their results are basic expression terms.