Question : Data between Date Range..


i want data between first date to last date

but why data is not displaying in datagrid1

but when i remove date range then statement working fine.
so i dont know whats wrong with query..

 
1:
2:
3:
4:
5:
6:
If Rs.State = 1 Then Rs.Close
          Rs.Open "Select Invo_Dtl.Invo_No, Invo_Dtl.Invo_Date as _Invo_Date_, Invo_Dtl.Invo_From as _From, Invo_Dtl.Invo_To as _To, Invo_Dtl.Invo_Truck_No as Truck_No, Invo_Dtl.Invo_TP_No as TP_No, Invo_Dtl.Invo_TP_Date as TP_Date, Invo_Dtl.Invo_Amount as Net_Amount, Invo_Dtl.Invo_Load as _Loading, Invo_Dtl.Invo_Insu as Insurance, Invo_Dtl.Invo_Vat_Cst as VAT_CST, Invo_Dtl.Invo_Total from Invo_Dtl where Invo_Dtl.Invo_Date >=#" & DTPicker1.Value & "# and Invo_Dtl.Invo_Date <=#" & DTPicker2.Value & "# and Invo_Dtl.Invo_Compy = '" & Text1.Text & "' and Invo_Dtl.Invo_Customer = '" & Text2.Text & "'", con, adOpenKeyset, adLockPessimistic
     
    If Rs.RecordCount > 0 Then
    
    Set DataGrid1.DataSource = Rs

Answer : Data between Date Range..

Date Picker value return date in a certain format see that and remove times part from date.
2. u r using
in where  clause >= or <= sign that may not  work
use between keyword

or to remove time from date
//
WHERE dbo.TimelessDate (RequestStart_Date) =dbo.TimelessDate (@from_date)
                  AND dbo.TimelessDate (RequestEnd_Date) = dbo.TimelessDate (@To_date)

// TimelessDate-- function   attached


1:
2:
3:
4:
5:
6:
7:
8:
9:
Create FUNCTION [dbo].[TimelessDate]  (@DateTime datetime)
RETURNS datetime
WITH EXECUTE AS CALLER
AS
BEGIN

return cast(floor(cast(@DateTime as float)) as datetime) 

end
Random Solutions  
 
programming4us programming4us