---
title: "Getting Error When use Date to Search"  
description: "Getting Error When use Date to Search"  
author: "marcel ethan"  
published: 2013-12-15  
updated: 2013-12-16  
canonical: https://www.mindstick.com/forum/1773/getting-error-when-use-date-to-search  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# Getting Error When use Date to Search

```
cmdDateReceivingStock = new SqlCommand("Select Distinct
Date FROM  OrderDetails
WHERE item_Received ='No'", conStock);        SqlDataAdapter da = new SqlDataAdapter(cmdDateReceivingStock);        DataSet ds = new DataSet();        da.Fill(ds);       
ddlOrderDate.DataTextFormatString = "{0:dd-MM-yyyy}";       
ddlOrderDate.DataSource = ds;       
ddlOrderDate.DataTextField = "Date";       
ddlOrderDate.DataBind();
```

After I [success](https://www.mindstick.com/articles/12957/best-tips-to-make-your-ghostwriting-experience-a-success) [convert the date](https://www.mindstick.com/forum/158272/how-to-convert-the-date-format-to-ut-in-json) into [dropdownlist](https://www.mindstick.com/articles/324837/how-to-bind-dropdownlist-in-mvc-core-from-database-using-entity-framework),but I getting this error"[Conversion](https://www.mindstick.com/forum/1734/conversion-from-32-bit-integer-to-4-chars) [failed when converting](https://www.mindstick.com/forum/23101/conversion-failed-when-converting-the-nvarchar-value-meetingid-to-data-type-int) date and/or time from [character](https://www.mindstick.com/articles/23551/an-investigate-distinctive-seafood-restaurant-for-your-image-stamp-character) string." when I use the date to [retrieve](https://www.mindstick.com/forum/34400/how-to-retrieve-form-values-in-controller-action) [data from database](https://www.mindstick.com/forum/34370/how-to-populate-google-charts-using-data-from-database-created-via-data-first-asp-dot-net-mvc)

## Replies

### Reply by Pravesh Singh

Hi Marcel,\

Try this in your sql query.

cmdDateReceivingStock = new SqlCommand("Select Distinct CONVERT(VARCHAR,Date,103) FROM

OrderDetails WHERE item_Received ='No'", conStock);


---

Original Source: https://www.mindstick.com/forum/1773/getting-error-when-use-date-to-search

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
