---
title: "conversion faild when converting date time from charachter string error"  
description: "conversion faild when converting date time from charachter string error"  
author: "ahmed salah"  
published: 2014-09-01  
updated: 2014-09-01  
canonical: https://www.mindstick.com/forum/2220/conversion-faild-when-converting-date-time-from-charachter-string-error  
category: "c#"  
tags: ["c#"]  
reading_time: 1 minute  

---

# conversion faild when converting date time from charachter string error

Hi guy when i run this [Stored procedure](https://www.mindstick.com/articles/803/using-stored-procedure-in-asp-dot-net) it give me [message error](https://www.mindstick.com/forum/159641/how-can-i-fix-an-outlook-message-error) \
\

[conversion](https://www.mindstick.com/forum/1734/conversion-from-32-bit-integer-to-4-chars) faild when converting [date time](https://www.mindstick.com/blog/386/retrieve-sql-server-installation-date-time) from charachter sting

stored procedure as following \

```
Create proc searchData    @StartDate datetime,     @EndDate datetimeasDeclare @SQLQuery as nvarchar(2000)SET @SQLQuery ='SELECT * from Employee Where (1=1)'   If (@StartDate is not NULL) AND (@EndDate is not NULL)         Set @SQLQuery = @SQLQuery + ' And (JoinDate          BETWEEN '+ @StartDate +' AND '+@EndDate+')'Exec (@SQLQuery)
```

JoinDate found in table [Employee](https://www.mindstick.com/articles/85431/remote-employee-training-tips-tricks) as [datetime](https://www.mindstick.com/forum/12949/how-to-validate-if-a-datetime-field-is-not-null-empty)

but when i make stored procedure as following

it work in formate dd/mm/yyyy and this is what i need

```
ALTER  proc [dbo].[searchData]@StartDate datetime @EndDate  datetime, asselect * from dbo.Employee e where JoinDate between @StartDate and @EndDate
```

Now what is the proplem in first stored procedure\
Please help [me if](https://answers.mindstick.com/qa/50259/tell-me-if-your-system-is-infected-by-a-virus-how-you-will-recover-the-data) possible \


---

Original Source: https://www.mindstick.com/forum/2220/conversion-faild-when-converting-date-time-from-charachter-string-error

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
