title: Coldfusion: Dealing with Null values in Date Field
body: <p>I've got this form with all kinds of employee certifications, I need to input a date. Sometimes this date will be months in the future other times the date will be undefined, null. </p>
  
  <p>Whenever I try to pass a null value to my CFC, I always get an error that looks like: </p>
  
  <blockquote>
    <p>The CPRADULTEXP argument passed to the addEmployee function is not of type date.</p>
  </blockquote>
  
  <p>My Form code: </p>
  
  <pre><code>&lt;!--- If null, set a default if not, set the default to database default ---&gt;
  &lt;cfif not isDefined("certificationsList.cprAdultExp")&gt;
  &lt;cfinput type="datefield" required="no" name="cprAdultExp" value="" &gt;
  &lt;cfelse&gt;
  &lt;cfinput type="datefield" required="no" name="cprAdultExp" value="#dateformat(certificationsList.cprAdultExp, "mm/dd/yyyy")#" &gt;
  &lt;/cfif&gt;
  </code></pre>
  
  <p>Form Processor: </p>
  
  <pre><code>&lt;!--- Is the date defined? ---&gt;
  &lt;cfif len(Trim("form.cprAdultExp"))  EQ 0&gt;
  &lt;cfinvokeargument name="cprAdultExp" value="#CreateODBCDate(Form.cprAdultExp)#"&gt;
  &lt;cfelse&gt;
  &lt;cfinvokeargument name="cprAdultExp" value=""&gt;
  &lt;/cfif&gt;    
  </code></pre>
  
  <p>Right now it's passing that null value, the database is set to handle/accept nulls. </p>
  
  <p>How can I fix? </p>