Click here to Skip to main content
12,453,672 members (86,768 online)
Rate this:
 
Please Sign up or sign in to vote.
See more: C# SQL ADO.NET
hi


i have two table in access I want to select values ​​based on date, now i write this code:

SELECT tblFishBank.CodeFish, tblFishBank.Mablagh, tblFishBank.SDate, tblFishBank.MDate, tblFishBank.Dis, tblProjeh.fldName, tblProjeh.fldFamil, tblFishBank.InsertDate, tblFishBank.InsertDate
FROM tblProjeh INNER JOIN tblFishBank ON tblProjeh.CodeProj = tblFishBank.CodeProj
WHERE (((tblFishBank.InsertDate)>=#8/20/2014#) AND ((tblFishBank.InsertDate)<=#8/21/2014#));


But when I run this code. No results, But when I remove this section of code:
WHERE (((tblFishBank.InsertDate)>=#8/20/2014#) AND ((tblFishBank.InsertDate)<=#8/21/2014#));


The result returned


How do I correct this code that returns a result between two dates? i use access
Posted 20-Aug-14 20:59pm
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 1

I would guess your parameter value is not in the right datetime format.
try replacing with:

WHERE tblFishBank.InsertDate between '20140820' and '20140822'
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 2

Try this
WHERE (((tblFishBank.InsertDate)>='8/20/2014') AND ((tblFishBank.InsertDate)<='8/21/2014'));
  Permalink  
Rate this: bad
 
good
Please Sign up or sign in to vote.

Solution 3

tanks for all

i try this and work

WHERE (((tblFishBank.InsertDate)>#8/20/2014#) AND ((tblFishBank.InsertDate)< #8/22/2014#));

i replacing >= with > and date 8/21/2014 to 8/22/2014 i added one day to date
  Permalink  

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month


Advertise | Privacy | Mobile
Web02 | 2.8.160826.1 | Last Updated 21 Aug 2014
Copyright © CodeProject, 1999-2016
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100