|
CreateODBCDate
DescriptionCreates
an ODBC date object.
ReturnsA date
object, in normalized ODBC date format.
Function syntaxCreateODBCDate(date)
Parameters
Parameter
|
Description
|
date
|
Date or date/time object in the range 100
AD–9999 AD.
|
UsageThis 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), Adobe
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".
Example<h3>CreateODBCDate Example</h3>
<cfif IsDefined("form.year")>
<p>Your date value, generated with CreateDateTime:</p>
<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>
<li>Formatted with CreateDateTime:
#CreateDateTime(form.year, form.month, form.day, form.hour, form.minute,
form.second)#</li>
<li>Formatted with CreateODBCDate: #CreateODBCDate(yourDate)#</li>
<li>Formatted with CreateODBCDateTime: #CreateODBCDateTime(yourDate)#</li>
</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>
<li>Formatted with CreateDateTime and DateFormat:
#DateFormat(CreateDateTime(form.year, form.month, form.day, form.hour,
form.minute, form.second))#</li>
<li>Formatted with CreateODBCDate and DateFormat:
#DateFormat(CreateODBCDate(yourDate), "mmmm d, yyyy")#</li>
<li>Formatted with CreateODBCDateTime and DateFormat:
#DateFormat(CreateODBCDateTime(yourDate), "d/m/yy")#</li>
</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>
|