Adobe COLDFUSION 9 Manual page 60

Developing applications
Hide thumbs Also See for COLDFUSION 9:
Table of Contents

Advertisement

DEVELOPING COLDFUSION 9 APPLICATIONS
The CFML Programming Language
You can also use the
IsDate
characters to a string before comparison to avoid incorrect interpretation.
Date-time functions and queries when ODBC is not supported
Many CFML functions, including the
time objects. ColdFusion creates Open Database Connectivity (ODBC) timestamp values when it converts date-time
objects to strings. As a result, you can get unexpected results when using dates with a database driver that does not
support ODBC escape sequences, or when you use SQL in a query of queries.
If you use SQL to insert data into a database or in a WHERE clause to select data from a database, and the database
driver does not support ODBC-formatted dates, use the
format for the driver. This rule also applies to queries of queries.
For example, the following SQL statement uses the
MyDate values in the future:
<cfquery name="MyQofQQ" dbtype="query">
SELECT *
FROM DateQuery
WHERE MyDate >= '#DateFormat(Now())#'
</cfquery>
The following query of queries fails with the error message "Error: {ts is not a valid date," because the ColdFusion
function returns an ODBC timestamp:
<cfquery name="MyQofQQ" dbtype="query">
SELECT *
FROM DateQuery
WHERE MyDate >= '#now()#'
</cfquery>
Using JavaCast with overloaded Java methods
You can overload Java methods so a class can have several identically named methods that differ only in parameter
data types. At run time, the Java virtual machine attempts to resolve the specific method to use, based on the types of
the parameters passed in the call. Because ColdFusion does not use explicit types, you cannot predict which version of
the method the virtual machine will use.
The ColdFusion
function helps you ensure that the right method executes by specifying the Java type of a
JavaCast
variable, as in the following example:
<cfset emp.SetJobGrade(JavaCast("int", JobGrade))>
The
function takes two parameters: a string representing the Java data type and the variable whose type you
JavaCast
are setting. You can specify the following Java data types: Boolean, int, long, float, double, and String.
For more information on the
Using quotation marks
To ensure that ColdFusion properly interprets string data, surround strings in single- or double-quotation marks. For
example, ColdFusion evaluates "10/2/2001" as a string that can be converted into a date-time object. However, it
evaluates 10/2/2001 as a mathematical expression, 5/2001, which evaluates to 0.00249875062469.
Examples of type conversion in expression evaluation
The following examples demonstrate ColdFusion expression evaluation.
function to determine whether a string can be interpreted as a date-time value, or to add
,
,
Now
CreateDate
CreateTime
DateFormat
DateFormat
function, see the CFML Reference.
JavaCast
Last updated 8/5/2010
, and
CreateDateTime
function to convert the date-time value to a valid
function in a query of queries to select rows that have
55
functions, return date-
Now

Advertisement

Table of Contents
loading

Table of Contents