title: How to convert separate date and time parameters to a valid datetime?
body: <p>I have a report with date and time (only an hour and minutes) parameters which are separate. The Date parameter is of type Date/Time, and the Time parameter is set as Text. I want to merge those two values into one because I want to pass a minimum number of arguments to the stored procedure. I tried to achieve that goal in many ways but SSRS returns an error for every attempt. </p>
  
  <p>If I try to use expression like this:</p>
  
  <pre><code>=Format(FormatDateTime(Parameters!startDate.Value, DateFormat.ShortDate).ToString() + Parameters!startTime.Value, "dd/MM/yyyy HH:mm")
  </code></pre>
  
  <p>SSRS returns this error:</p>
  
  <blockquote>
    <p>Error conterting data type nvarchar to datetime.</p>
  </blockquote>
  
  <p>And when I tried to use <code>Datetime.Parse</code> like this:</p>
  
  <pre><code>=DateTime.Parse(Format(FormatDateTime(Parameters!startDate.Value, DateFormat.ShortDate).ToString() + Parameters!startTime.Value, "dd/MM/yyyy HH:mm"))
  </code></pre>
  
  <p>SSRS said:</p>
  
  <blockquote>
    <p>The Value expression for the query parameter '@startDate' contains an error: The string was not recognized as a valid DateTime. There is a unknown word starting at index 0.</p>
  </blockquote>
  
  <p>When I removed the <code>FormatDateTime</code> function I get yet another error:</p>
  
  <blockquote>
    <p>The Value expression for the query parameter '@startDate' contains an error: Input string was not in a correct format.</p>
  </blockquote>
  
  <p>Do you have any ideas how to write this expression correctly?</p>
  
  <p>PS. I use SSRS 2008 R2.</p>