---
title: "Selecting records between two dates nothing show although it have records in database why"  
description: "Selecting records between two dates nothing show although it have records in database why"  
author: "ahmed salah"  
published: 2014-08-30  
updated: 2014-08-30  
canonical: https://www.mindstick.com/forum/2209/selecting-records-between-two-dates-nothing-show-although-it-have-records-in-database-why  
category: "c#"  
tags: ["c#", "db database", "sql server 2012", "select record between two dates", "select query"]  
reading_time: 1 minute  

---

# Selecting records between two dates nothing show although it have records in database why

I have [database](https://www.mindstick.com/articles/12226/use-of-database-in-sencha-extjs-and-insert-record-from-user-form-using-ajax) for hr have [Employee](https://www.mindstick.com/articles/85431/remote-employee-training-tips-tricks) table\
Employee table has JoinDate with [datatype](https://www.mindstick.com/forum/160266/explain-the-datatype-data-annotation-and-its-significance-in-data-entry-and-display) [datetime](https://www.mindstick.com/forum/12949/how-to-validate-if-a-datetime-field-is-not-null-empty)\
I need to make [dynamic search](https://answers.mindstick.com/qa/34543/what-are-the-targeting-options-in-dynamic-search-ad-in-google-adword) so that i make dynamic [stored procedure](https://www.mindstick.com/articles/803/using-stored-procedure-in-asp-dot-net)

ViewEmployee23

SELECT [CONVERT](https://www.mindstick.com/forum/2093/configurationmanager-appsettings-convert-n-to-n-why)(varchar, DriverID) AS EmployeeID, \
CONVERT(varchar, dbo.Employee.JoinDate, 103) AS JoinDate, CONVERT(varchar, dbo.Employee.ResignDate, 103) AS ResignDate \
FROM dbo.Employee \
and Stored procedure like following :\
ALTER Procedure [dbo].[sp_EmployeeSelect5]\
@JoinDate nvarchar(20)\
@StartDate nvarchar(20)\
@EndDate nvarchar(20)\
as\
Declare @SQLQuery as nvarchar(2000)\
SET @SQLQuery ='SELECT * from ViewEmployee23 Where (1=1)' \
IF @StartDate <> ''\
SET @SQLQuery = @SQLQuery + ' AND (JoinDate <= '''+ @StartDate +''') '\
IF @EndDate <> ''\
SET @SQLQuery = @SQLQuery + ' AND (JoinDate <= '''+ @EndDate +''') '

When i test query in query analzer i do following\
select * from ViewEmployee23 where JoinDate>='01/01/2014' and JoinDate<='01/04/2014'\
it show nothing \
select * from dbo.Employee where JoinDate>='01/01/2014' and JoinDate<='01/04/2014' \
it show nothing \
select * from dbo.Employee where JoinDate>='2014/01/01' and JoinDate<='2014/04/01'\
it show one record exist and this is acctually true result\
Now how i get [records](https://www.mindstick.com/forum/34640/how-to-create-a-stored-procedure-for-display-all-records) and filter between two dates fromdate todate based on formate\
dd/mm/yyyy in dynamic stored procedure search

what i change


---

Original Source: https://www.mindstick.com/forum/2209/selecting-records-between-two-dates-nothing-show-although-it-have-records-in-database-why

Copyright © MindStick Software Pvt. Ltd. This Markdown version is provided for developers, AI systems, and offline reading.
