Showing posts with label filter. Show all posts
Showing posts with label filter. Show all posts

Wednesday, March 21, 2012

Problem getting Recoreds from Store Proedure Between Dates...

i have a gridView and i want to get the recoreds between specific dates.. so i put two calendars to select the dates...

and they will filter the recoreds..(i seleced dates and it returns non recors and theres recored betwenn those dates and in a SQL View it works )

What can i do? Thanks

Store Proceure Function:

CREATE PROCEDUREsp_FindTnoaGrid@.SearchTnoanvarchar(14),@.beginDateas nvarchar(50),@.endDateas nvarchar(50)AS-- order by dbo.V_tnuot.t_erech desc--if (@.beginDate='%')or (@.endDate='%')SELECT dbo.V_tnuot.kod_lakoha, dbo.V_tnuot.t_erech, dbo.V_tnuot.t_peula, dbo.V_tnuot.scum_peulaassum, dbo.V_tnuot.strHpoalimSugKodTnua, dbo.V_tnuot.DescSugPeula,cast(year(cast(@.beginDateas datetime))as nvarchar)+'-'+cast(month(cast(@.beginDateas datetime))as nvarchar)+'-'+cast(day(cast(@.beginDateas datetime))as nvarchar)as try, dbo.V_tnuot.Hpoalim_HodeshSaharFROM dbo.V_tnuotLEFTOUTER JOIN dbo.tblCategTnuot_KodPeulaON dbo.V_tnuot.strHpoalimSugKodTnua = dbo.tblCategTnuot_KodPeula.idKodTnuaWHERE ( kod_lakoha = @.SearchTnoa)if (@.beginDate<>'%')and (@.endDate<>'%')SELECT dbo.V_tnuot.kod_lakoha, dbo.V_tnuot.t_erech, dbo.V_tnuot.t_peula, dbo.V_tnuot.scum_peulaassum, dbo.V_tnuot.strHpoalimSugKodTnua, dbo.V_tnuot.DescSugPeula, dbo.V_tnuot.Hpoalim_HodeshSaharFROM dbo.V_tnuotLEFTOUTER JOIN dbo.tblCategTnuot_KodPeulaON dbo.V_tnuot.strHpoalimSugKodTnua = dbo.tblCategTnuot_KodPeula.idKodTnuaWHERE ( kod_lakoha = @.SearchTnoa)and (dbo.V_tnuot.t_peulaBETWEENcast(@.beginDateas datetime)andcast(@.endDateas datetime) )GO

What happens if you call the stored procedure directly e.g. from a query window in SQL Server Management Studio, passing in the appropriate parameters? Do you get the results you expect?

Are you tripping up over the classic "time" issue - DateTime fields don't just have a date, they have a time component so "2007-08-21" is not the same as "2007-08-21 14:23:08" etc.