Wrox Programmer Forums
| 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 software programmers and website developers including Wrox book authors and readers. New member registration was closed in 2019. New posts were shut off and the site was archived into this static format as of October 1, 2020. If you require technical support for a Wrox book please contact http://hub.wiley.com
  #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.

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

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

  #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
  #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~



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





Powered by vBulletin®
Copyright ©2000 - 2020, Jelsoft Enterprises Ltd.
Copyright (c) 2020 John Wiley & Sons, Inc.