469,275 Members | 1,782 Online
Bytes | Developer Community
New Post

Home Posts Topics Members FAQ

Post your question to a community of 469,275 developers. It's quick & easy.

SQL Date Between Query

2
Hey guys, I'm in need of your help!
I have an access database with a field called datee (Yes it has 2 e's) which is set to memo. In there is dates with the format dd/mm/yyyy. I need to develop a query to select between two dates.
e.g 12/02/2002 12/02/2003
I have tried so many things, from the BETWEEN function, to the ODER By function but to no avail. The between function only brings back results between the the dd section and ignores the month and year altogether.

<code>
SELECT *
FROM tbldata
WHERE datee BETWEEN ='#Form.startdate#'' AND '#Form.enddate#'
</code>

Any help greatly appreciated
thanks
Jul 11 '07 #1
3 12566
Vidhura
99
Hey guys, I'm in need of your help!
I have an access database with a field called datee (Yes it has 2 e's) which is set to memo. In there is dates with the format dd/mm/yyyy. I need to develop a query to select between two dates.
e.g 12/02/2002 12/02/2003
I have tried so many things, from the BETWEEN function, to the ODER By function but to no avail. The between function only brings back results between the the dd section and ignores the month and year altogether.

<code>
SELECT *
FROM tbldata
WHERE datee BETWEEN ='#Form.startdate#'' AND '#Form.enddate#'
</code>

Any help greatly appreciated
thanks

SELECT *
FROM tbldata
WHERE datee BETWEEN startdate AND enddate

before giving the value from form,convert the startdate and endate to datetime type
Jul 11 '07 #2
xres
2
SELECT *
FROM tbldata
WHERE datee BETWEEN startdate AND enddate

before giving the value from form,convert the startdate and endate to datetime type
How would I go about converting it to datetime?
thanks
Jul 11 '07 #3
Generate two new variables

Expand|Select|Wrap|Line Numbers
  1. DECLARE dtStart as Date
  2. DECLARE dtEnd as Date
  3.  
  4. dtStart = CDate (Form.startdate)
  5. dtEnd = CDate (Form.enddate)
  6.  
Then :

Expand|Select|Wrap|Line Numbers
  1. SELECT *
  2. FROM tbldata
  3. WHERE datee BETWEEN dtStart AND dtEnd
  4.  
Jul 11 '07 #4

Post your reply

Sign in to post your reply or Sign up for a free account.

Similar topics

4 posts views Thread by Russell | last post: by
10 posts views Thread by Kenneth | last post: by
7 posts views Thread by Nicolae Fieraru | last post: by
4 posts views Thread by Peter Bailey | last post: by
12 posts views Thread by Steve Elliott | last post: by
10 posts views Thread by Daniel | last post: by
2 posts views Thread by sixdeuce62 | last post: by
reply views Thread by zhoujie | last post: by
reply views Thread by suresh191 | last post: by
By using this site, you agree to our Privacy Policy and Terms of Use.