We help IT Professionals succeed at work.

Data between Date Range..

crystalsoft
crystalsoft used Ask the Experts™
on

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..

 
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

Open in new window

Comment
Watch Question

Do more with

Expert Office
EXPERT OFFICE® is a registered trademark of EXPERTS EXCHANGE®
Commented:
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



Create FUNCTION [dbo].[TimelessDate]  (@DateTime datetime)
RETURNS datetime
WITH EXECUTE AS CALLER
AS
BEGIN

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

end

Open in new window

Author

Commented:

Thanks

between keyword is working

Now i know about between also... :-)

Thanks again

Author

Commented:

(Between)
always i will remember :-)