title: How to use CodeObjectCreateExpression for System.DateTime in C# codeDom
body: <p>Here i the method 'BOOL()' returns a Boolean value.
  Now i need to do similar thing of returning a DateTime value. When i used,</p>
  
  <pre><code>new CodePrimitiveExpression(DATETIME());
  </code></pre>
  
  <p>where 'DATETIME()' returns a DateTime value.
  But i got the below exception when i tried CodePrimitiveExpression, </p>
  
  <pre><code>Invalid Primitive Type: System.DateTime. Consider using CodeObjectCreateExpression.
  </code></pre>
  
  <p><strong>So how  can i use CodeObjectExpression to get a DateTime value.?</strong></p>
  
  <p>Here is the code snippet attached.</p>
  
  <pre><code>if (p.ParameterType == typeof(System.Boolean))
                  return new CodeVariableDeclarationStatement(p.ParameterType, options.sVariableNamePrix + p.Name,
                      new CodePrimitiveExpression(BOOL()));
  else if (p.ParameterType == typeof(System.DateTime))
                  return new CodeVariableDeclarationStatement(p.ParameterType, options.sVariableNamePrix + p.Name,
                     // new CodeObjectCreateExpression(DATETIME()));
  </code></pre>