Wrox Programmer Forums

Need to download code?

View our list of code downloads.

Go Back   Wrox Programmer Forums > ASP.NET and ASP > ASP 3 Classic ASP Active Server Pages 3.0 > Classic ASP Databases
Password Reminder
Register
| FAQ | Members List | Calendar | Search | Today's Posts | Mark Forums Read
Classic ASP Databases Discuss using ASP 3 to work with data in databases, including ASP Database Setup issues from the old P2P forum on this specific subtopic. See also the book forum Beginning ASP.NET Databases for questions specific to that book. NOT for ASP.NET 1.0, 1.1, or 2.0.
Welcome to the p2p.wrox.com Forums.

You are currently viewing the Classic ASP Databases section of the Wrox Programmer to Programmer discussions. This is a community of tens of thousands of software programmers and website developers including Wrox book authors and readers. As a guest, you can read any forum posting. By joining today you can post your own programming questions, respond to other developers’ questions, and eliminate the ads that are displayed to guests. Registration is fast, simple and absolutely free .
DRM-free e-books 300x50
Reply
 
Thread Tools Search this Thread Display Modes
  #1 (permalink)  
Old February 22nd, 2005, 06:53 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default * where date >= '"& dateVar &"' order by date

Hello.

I've been trying to use a form value "vStartWeekOnWhatDay" to select only that data from the database that is >= the "vStartWeekOnWhatDay" value...


My select statement:
--------------------------------------------------------
sSQL = "SELECT * FROM List WHERE date >= '"& vStartWeekOnWhatDay & "' ORDER BY date"
--------------------------------------------------------


Error received:
--------------------------------------------------------
Microsoft OLE DB Provider for ODBC Drivers error '80040e07'

[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
--------------------------------------------------------


Any ideas? I've tried cdate(), formatDate(x,x), even separating the date variable into "day"/"month"/"year"

Thank you for hte help.

Reply With Quote
  #2 (permalink)  
Old February 22nd, 2005, 09:12 PM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

please check what vStartWeekOnWhatDay variable stores.

sSQL = "SELECT * FROM List WHERE [date] >= '"& vStartWeekOnWhatDay & "' ORDER BY date"

In the above SQL statement, "date" field is of what datatype?


Om Prakash
Reply With Quote
  #3 (permalink)  
Old February 22nd, 2005, 10:33 PM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

thanks for the message...

The database "date" datatype is date/time (medium date)... I tried changing to short date with no luck either.

The variable "vStartWeekOnWhatDay" = 22/2/2005 (when I do a response.write)

thanks in advance.

Reply With Quote
  #4 (permalink)  
Old February 23rd, 2005, 12:13 AM
Friend of Wrox
 
Join Date: Jun 2003
Location: , , Denmark.
Posts: 184
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via MSN to Jonax
Default

Access expects a date to be enclosed in #s...

Reply With Quote
  #5 (permalink)  
Old February 23rd, 2005, 01:01 PM
Friend of Wrox
Points: 2,473, Level: 20
Points: 2,473, Level: 20 Points: 2,473, Level: 20 Points: 2,473, Level: 20
Activity: 0%
Activity: 0% Activity: 0% Activity: 0%
 
Join Date: May 2004
Location: India
Posts: 642
Thanks: 0
Thanked 43 Times in 42 Posts
Default

Jonax is correct...

Query should be:

sSQL = "SELECT * FROM List WHERE [date] >= #"& vStartWeekOnWhatDay & "# ORDER BY date"



Om Prakash
Reply With Quote
  #6 (permalink)  
Old February 24th, 2005, 10:11 AM
Registered User
 
Join Date: Sep 2004
Location: , , .
Posts: 6
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thanks guys... after a bit of learning I figured it out based on Jonax's response about encapsulating the #dateVariable#... I'm just here to post my working code to help someone else (thank you both):

----------------------------------------------------------------

vStartWeekOnWhatDay = request.form("changeWeekToDate") 'grabs the date value from the form

if vStartWeekOnWhatDay = "" then
    'set to today if no form value has been set
    vStartWeekOnWhatDay = date()
end if

'I had to break the date down into mm/dd/yyyy

vStartWeekOnWhatDayDay = day(vStartWeekOnWhatDay)
vStartWeekOnWhatDayMonth = Month(vStartWeekOnWhatDay)
vStartWeekOnWhatDayYear = Year(vStartWeekOnWhatDay)

vStartWeekOnWhatDay = vStartWeekOnWhatDayMonth&"/"&vStartWeekOnWhatDayDay&"/"&vStartWeekOnWhatDayYear

sSQL = "SELECT * FROM List WHERE date >= # " & cDate(vStartWeekOnWhatDay ) & " # order by date"

----------------------------------------------------------------
~happy coding~

Reply With Quote
Reply


Thread Tools Search this Thread
Search this Thread:

Advanced Search
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is Off
HTML code is Off
Trackbacks are Off
Pingbacks are On
Refbacks are Off


Similar Threads
Thread Thread Starter Forum Replies Last Post
Server Date & Time RICHBIRD Beginning VB 6 3 November 15th, 2007 08:59 AM
Linux & KDE & C++ & QT & MYSQL & Kdevelop Munnnki Linux 0 January 2nd, 2005 05:41 PM
bindings & date format miguel.ossa C# 12 August 28th, 2004 06:23 AM
XML from a DB recordset (removal of <>) Thodoris XML 3 July 13th, 2004 12:28 AM
Date Time - From & To Passing shrishankaraan Crystal Reports 0 May 26th, 2004 10:28 PM



All times are GMT -4. The time now is 05:59 PM.


Powered by vBulletin®
Copyright ©2000 - 2019, Jelsoft Enterprises Ltd.
© 2013 John Wiley & Sons, Inc.