Home | Advertising Info4 USERS CURRENTLY ONLINE   
PowerASP
   Site Search Contact Us Sunday, May 12, 2024  

  Active TopicsActive Topics  Display List of Forum MembersMemberlist  Search The ForumSearch  HelpHelp
  RegisterRegister  LoginLogin
Classic ASP - Database Issues
 PowerASP Code Help Area : Classic ASP - Database Issues
Subject Topic: SQL and between statement Post ReplyPost New Topic
Author
Message << Prev Topic | Next Topic >>
cgauss
Newbie
Newbie


Joined: February/06/2005
Online Status: Offline
Posts: 1
Posted: February/06/2005 at 1:09pm | IP Logged Quote cgauss

I am trying to pull in some dates from a access database table, but for some reason I am getting unexpected results. 

Instead of the dates between the range I am getting every single date.  Any ideas as to what I am doing wrong?  Im guessing it is something very simple.

Here is the code I am using:

Dim cnn,rst
Dim date1, date2

date1 = CDate(date())
date2 = CDate(date()+30)

set cnn = Server.CreateObject("ADODB.Connection")
Set rst = Server.CreateObject("ADODB.Recordset")
cnn.Open "Provider=Microsoft.Jet.OLEDB.4.0;Data Source=" & Server.MapPath(strEzDBPath2) ' "../db/ez.mdb"
sqltext = "SELECT * FROM tblCalendar WHERE " & CDATE(date) & " BETWEEN " & date1 & " AND " & date2 &""
set rst = cnn.Execute(sqltext)
Response.Write rst("Date")

if not rst.EOF then 'just added
while not rst.EOF

Response.Write rst("Date")

rst.movenext
wend
end if
rst.close
cnn.close

Back to Top View cgauss's Profile Search for other posts by cgauss
 
ThePriest
Newbie
Newbie
Avatar

Joined: February/16/2005
Location: South Africa
Online Status: Offline
Posts: 2
Posted: February/16/2005 at 7:20am | IP Logged Quote ThePriest

Try:
sqltext = "SELECT * FROM tblCalendar WHERE date >= " & date1 & " AND date <= " & date2

Back to Top View ThePriest's Profile Search for other posts by ThePriest
 
firas_TheGeek
Newbie
Newbie
Avatar

Joined: May/27/2006
Location: Oman
Online Status: Offline
Posts: 28
Posted: May/27/2006 at 10:02am | IP Logged Quote firas_TheGeek

first you have to change the field name in the database from Date to sometihng else

because the word date is reserved for the system so when u use it the server will conflict thinking that date is a function to show the date and doesnt know that you mean the field name

second the syntax for the between is

SELECT column_name FROM table_name WHERE column_name BETWEEN value1 AND value2
so after the word WHERE must be a column_Name not the date or the field date
 
try thant and should work
 
Best Regards


__________________
Firas S Assaad (TheGeek)
firas489@gmail.com
0096892166434
http://firas-thegeek.blogspot.com
Back to Top View firas_TheGeek's Profile Search for other posts by firas_TheGeek Visit firas_TheGeek's Homepage
 

If you wish to post a reply to this topic you must first login
If you are not already registered you must first register

  Post ReplyPost New Topic
Printable version Printable version

Forum Jump
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot delete your posts in this forum
You cannot edit your posts in this forum
You cannot create polls in this forum
You cannot vote in polls in this forum

   Active Server Pages Rule The World
Contact Us  
All artwork, design & content contained in this site are Copyright © 1998 - 2024 PowerASP.com and Christopher J. Williams
Banner ads ,other site logos, etc are copyright of their respective companies.
STATS Unless otherwise noted - All Rights Reserved.

Active Server Pages asp source code database MS SQL MS Access .mdb adovbs.inc cookies calendar codes sql commands scripts asp programming tutorials iis web server components CJWSoft ASPProtect ASPBanner ASPClassifieds www.aspprotect.com, www.cjwsoft.com,www.aspclassifieds.com,www.aspphotogallery.com