Returns a valid date/time object.
See also CreateDate, CreateTime, CreateODBCDateTime, and Now.
CreateDateTime(year, month, day, hour, minute, second)
Number representing the year in the range 100-9999. Years from 0 to 29 are interpreted as 21st century values. Years 30 to 99 are interpreted as 20th century values.
Number representing the month of the year, ranging from 1 (January) to 12 (December).
Number representing the day of the month, ranging from 1 to 31.
Number representing the hour, ranging from 0 to 23.
Number representing the minute, ranging from 0 to 59.
Number representing the second, ranging from 0 to 59.
<!--- This example shows how to use CreateDateTime ---> <HTML> <HEAD> <TITLE> CreateDateTime Example </TITLE> </HEAD> <BODY bgcolor=silver> <H3>CreateDateTime Example</H3> <CFIF IsDefined("form.year")> Your date value, presented using different CF date functions: <CFSET yourDate=CreateDateTime(form.year, form.month, form.day, form.hour, form.minute, form.second)> <CFOUTPUT> <UL> <LI>Built with CreateDate: #CreateDate(form.year, form.month,form.day)# <LI>Built with CreateDateTime: #CreateDateTime(form.year, form.month, form.day, form.hour, form.minute,form.second)# <LI>Built with CreateODBCDate: #CreateODBCDate(yourDate)# <LI>Built with CreateODBCDateTime: #CreateODBCDateTime(yourDate)# </UL> <P>The same value can be formatted with dateFormat: <UL> <LI>Built with CreateDate: #DateFormat(CreateDate (form.year,form.month,form.day), "mmm-dd-yyyy")# <LI>Built with CreateDateTime: #DateFormat(CreateDateTime (form.year, form.month, form.day, form.hour, form.minute, form.second))# <LI>Built with CreateODBCDate: #DateFormat(CreateODBCDate(yourDate), "mmmm d, yyyy")# <LI>Built with CreateODBCDateTime: #DateFormat(CreateODBCDateTime(yourDate), "d/m/yy")# </UL> </CFOUTPUT> </CFIF> <FORM ACTION="createdatetime.cfm" METHOD="POST"> <!---------------------------------------------------------------------- The following hidden fields provide server-side validation of required fields and ensures that the data type is numeric. -----------------------------------------------------------------------> <INPUT TYPE="hidden" NAME="year_Required"> <INPUT TYPE="hidden" NAME="month_Required"> <INPUT TYPE="hidden" NAME="day_Required"> <INPUT TYPE="hidden" NAME="hour_Required"> <INPUT TYPE="hidden" NAME="minute_Required"> <INPUT TYPE="hidden" NAME="second_Required"> <INPUT TYPE="hidden" NAME="year_Integer"> <INPUT TYPE="hidden" NAME="month_Range" Value="Min=1 Max=12"> <INPUT TYPE="hidden" NAME="day_Range" Value="Min=1 Max=31"> <INPUT TYPE="hidden" NAME="hour_Range" Value="Min=1 Max=24"> <INPUT TYPE="hidden" NAME="minute_Range" Value="Min=1 Max=60"> <INPUT TYPE="hidden" NAME="second_Range" Value="Min=0 Max=60"> <P>Please enter the year, month and day in integer FORMat for the date value you would like to view: <PRE> Year <INPUT TYPE="Text" NAME="year" VALUE="1999"> Month <INPUT TYPE="Text" NAME="month" VALUE="6"> Day <INPUT TYPE="Text" NAME="day" VALUE="8"> Hour <INPUT TYPE="Text" NAME="hour" VALUE="16"> Minute <INPUT TYPE="Text" NAME="minute" VALUE="12"> Second <INPUT TYPE="Text" NAME="second" VALUE="0"> </PRE> <P><INPUT TYPE="Submit" NAME=""> <INPUT TYPE="RESET"> </FORM> </BODY> </HTML>