Wrox Programmer Forums
|
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
 
Old March 1st, 2004, 07:29 PM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default Please Help

Hello!
I have this query:
SELECT [namefield] from [nametable] where date1> #"&Date()&"#
Thia query has to return the [namefields] that have date1 greater than current date. Instead of this it returns all the namefields of the table. Even the namefields that have date1 less than current date. I cant explain why.
I would appreciate any help because I am quite confused
Thanks

 
Old March 2nd, 2004, 04:36 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

I assume you are using MsAccess as your database. Otherwise you wouldn't use # signs. Try setting a variable for Date() and see what happens as follows...

MyDate = Date()
"select FIELD from TABLE where Date1 > #" & MyDate & "#"

 
Old March 2nd, 2004, 05:59 AM
Registered User
 
Join Date: Mar 2004
Posts: 2
Thanks: 0
Thanked 0 Times in 0 Posts
Default

Thank you for your suggestion. But it does not seem to work.
From what I have understand the query SELECT [namefield] from [nametable] where date1> #"&Date()&"# returns the namefields that have month > the number of current day. ie
if date1=15/2/2004 and Date()=1/3/2004 then this condition return the namefield but this is wrong.
if date1=15/2/2004 and Date()=3/3/2004 then does not return the namefield. The date has short format DD/MM/YYYY

 
Old March 3rd, 2004, 02:45 PM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 171
Thanks: 0
Thanked 1 Time in 1 Post
Default

Your date format is a little different than the standard format I had. Try this.

ThisDate = Date()
MyDay = Day(ThisDate)
MyMonth = Month(ThisDate)
MyYear = Year(ThisDate)
MyDate = MyDay & "/" MyMonth & "/" & MyYear

"select FIELD from TABLE where Date1 > #" & MyDate & "#"

perhaps even...

"select FIELD from TABLE where Date1 > #" & cDate(MyDate) & "#"









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