title: Conversion failed when converting date and/or time from character string
body: <p>This query is working fine in Sql Server Management Studio, But when I try it to run in a dataset &amp; pass Date(@Param2 &amp; @Pram3) from datetime picker, its throwing an exception Conversion failed. I don't know whats wrong with that, my other queries are working fine.Is this happening because of UNION ALL? </p>
  
  <p><strong>.NET Code</strong></p>
  
  <pre><code>startDatePicker.Format = DateTimePickerFormat.Short;
  endDatePicker.Format = DateTimePickerFormat.Short;
  DataTable ntwTable = ntw.GetData(owner,start,end);
  start = startDatePicker.Value.ToShortDateString();
  end = endDatePicker.Value.ToShortDateString();
  </code></pre>
  
  <p><strong>SQL</strong></p>
  
  <pre><code>SELECT        o.Name, SUM(sq.SQuantity * sq.SRate) AS TotalSale, SUM(sq.PrQuantity * sq.PrRate) AS TotalPurchase, (SUM(sq.PQuantity) - SUM(sq.SQuantity)) 
                                   * (SUM(sq.PQuantity * sq.PRate) / SUM(sq.PQuantity)) AS Inventory
          FROM            (SELECT        OwnerId, CompanyId, Quantity AS PQuantity, RatePerShare AS PRate, 0 AS SQuantity, 0 AS SRate, 0 AS PrQuantity, 0 AS PrRate, Date
                                    FROM            Purchase
                                    UNION ALL
                                    SELECT        OwnerId, CompanyId, 0 AS PQuantity, 0 AS PRate, 0 AS SQuantity, 0 AS SRate, Quantity AS PrQuantity, RatePerShare AS PrRate, Date
                                    FROM            Purchase AS pr
                                    UNION ALL
                                    SELECT        OwnerId, CompanyId, Quantity AS PQuantity, 0 AS PRate, 0 AS SQuantity, 0 AS SRate, 0 AS PrQuantity, 0 AS PrRate, Date
                                    FROM            Bonus
                                    UNION ALL
                                    SELECT        OwnerId, CompanyId, Quantity AS PQuantity, CostOfShare AS PRate, 0 AS SQuantity, 0 AS SRate, 0 AS PrQuantity, 0 AS PrRate, Date
                                    FROM            RightShare
                                    UNION ALL
                                    SELECT        OwnerId, CompanyId, 0 AS PQuantity, 0 AS PRate, Quantity AS SQuantity, RatePerShare AS SRate, 0 AS PrQuantity, 0 AS PrRate, Date
                                    FROM            Sales) AS sq INNER JOIN
                                   Owner AS o ON o.OwnerId = sq.OwnerId
          WHERE        (o.OwnerId = @Param1) AND (sq.Date BETWEEN @Param2 AND @Param3)
          GROUP BY sq.CompanyId, o.Name
  </code></pre>