CreateDateTime

Description

Returns a valid date/time object.

Category

Date and time functions

Syntax

CreateDateTime(year, month, day, hour, minute, second) 

See also

CreateDate, CreateTime, CreateODBCDateTime, Now

Parameters

Parameter
Description
year
Number in the range 100-9999
month
Number in the range 1 (January)-12 (December)
day
Number in the range 1-31
hour
Number in the range 0-23
minute
Number in the range 0-59
second
Number in the range 0-59

Usage

Year values 0 - 29 are interpreted as 21st century dates. Year values 30 - 99 are interpreted as 20th century dates.

Example

<!--- 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>

<cfform action = "createdatetime.cfm" method = "POST">
<P>Please enter the year, month and day in integer format for 
the date value you would like to view:
<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>
</body>
</html>