View comments | RSS feed
Contents > CFML Reference > ColdFusion Functions > CreateODBCDate PreviousNext

CreateODBCDate

Creates an ODBC date object.

A date object, in normalized ODBC date format.

Date and time functions

CreateODBCDate(date)

CreateDate, CreateODBCDateTime

Parameter

Description

date

Date or date/time object in the range 100 AD-9999 AD.

This function does not parse or validate values. To ensure that dates are entered and processed correctly (for example, to ensure that a day/month/year entry is not confused with a month/day/year entry, and so on), Macromedia recommends that you parse entered dates with the DateFormat function, using the mm-dd-yyyy mask, into three elements. Ensure that values are within appropriate ranges; for example, to validate a month value, use the attributes validate = "integer" and range = "1,12".

<h3>CreateODBCDate Example</h3>
<CFIF IsDefined("form.year")>
<p>Your date value, generated with CreateDateTime:
<CFSET yourDate = CreateDateTime(form.year, form.month, form.day, form.hour,
form.minute, form.second)> <cfoutput> <ul> <li>Formatted with CreateDate: #CreateDate(form.year, form.month, form.day)# <li>Formatted with CreateDateTime: #CreateDateTime(form.year, form.month, form.day, form.hour, form.minute,
form.second)# <li>Formatted with CreateODBCDate: #CreateODBCDate(yourDate)# <li>Formatted with CreateODBCDateTime: #CreateODBCDateTime(yourDate)# </ul> <p>The same value can be formatted with DateFormat: <ul> <li>Formatted with CreateDate and DateFormat: #DateFormat(CreateDate(form.year,form.month, form.day), "mmm-dd-yyyy")# <li>Formatted with CreateDateTime and DateFormat: #DateFormat(CreateDateTime(form.year, form.month, form.day, form.hour,
form.minute, form.second))# <li>Formatted with CreateODBCDate and DateFormat: #DateFormat(CreateODBCDate(yourDate), "mmmm d, yyyy")# <li>Formatted with CreateODBCDateTime and DateFormat: #DateFormat(CreateODBCDateTime(yourDate), "d/m/yy")# </ul> </cfoutput> </CFIF> <CFFORM ACTION="createodbcdate.cfm" METHOD="POST"> <p>Enter the year, month and day, as integers: <PRE> Year <CFINPUT TYPE="Text" NAME="year" VALUE="1998" VALIDATE="integer" REQUIRED="Yes"> Month <CFINPUT TYPE="Text" NAME="month" VALUE="6" RANGE="1,12" MESSAGE="Please enter a month (1-12)" VALIDATE="integer" REQUIRED="Yes"> Day <CFINPUT TYPE="Text" NAME="day" VALUE="8" RANGE="1,31" MESSAGE="Please enter a day of the month (1-31)" VALIDATE="integer" REQUIRED="Yes"> Hour <CFINPUT TYPE="Text" NAME="hour" VALUE="16" RANGE="0,23" MESSAGE="You must enter an hour (0-23)" VALIDATE="integer" REQUIRED="Yes"> Minute <CFINPUT TYPE="Text" NAME="minute" VALUE="12" RANGE="0,59" MESSAGE="You must enter a minute value (0-59)" VALIDATE="integer" REQUIRED="Yes"> Second <CFINPUT TYPE="Text" NAME="second" VALUE="0" RANGE="0,59" MESSAGE="You must enter a value for seconds (0-59)" VALIDATE="integer" REQUIRED="Yes"> </PRE> <p><INPUT TYPE="Submit" NAME=""> <INPUT TYPE="RESET"> </cfform>

Contents > CFML Reference > ColdFusion Functions > CreateODBCDate PreviousNext

ColdFusion 9 | ColdFusion 8 | ColdFusion MX 7 | ColdFusion MX 6.1 | ColdFusion MX | Forums | Developer Center | Bug Reporting

Version 6.1

Comments are no longer accepted for ColdFusion MX 6.1. ColdFusion 8 is the current version.

Comments


theriversideweb said on May 11, 2005 at 11:52 AM :
Createodbcdate() seems to contain some hidden time information in MX6.1, ie:

createodbcdate(createdate(year(now()),month(now()),day(now())))>
is not the same as createodbcdate(now()).

Although the results look the identical when displayed, when you compare them with a cfif, datediff or datecompare they are not equal. createodbcdate(now()) seems to have hidden time information. I am sure it shouldn't, does anyone know why it does?

Thanks in advance.
No screen name said on May 13, 2005 at 1:03 PM :
I believe that the integer portion of the function is the date stamp and the decimal portion is the time stamp.

 

RSS feed | Send me an e-mail when comments are added to this page | Comment Report

Current page: http://livedocs.adobe.com/coldfusion/6.1/htmldocs/functi49.htm