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 August 5th, 2004, 10:20 PM
Authorized User
 
Join Date: Mar 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to gmoney060 Send a message via MSN to gmoney060
Default Database Date Problem

I am trying to select only recordsets from a database were the date field is the same as todays date

database:
| EventID | Date |

Code that i have problems with:
Code:
<%
    'Declares Variables
    Dim dbName2
    Dim ObjConn2
    Dim events

    'Sets Up Database Connection
    dbName2 = "/fpdb/events.mdb"
    ObjConn2 = "Provider=Microsoft.Jet.OLEDB.4.0;Persist Security Info=False;Data Source=" & Server.MapPath(dbName2)

    'Connects to Database
    Set events = Server.CreateObject("ADODB.RecordSet")
    events.Open "SELECT * FROM Events Where date="&date(),ObjConn2,1,2
    Do While Not events.EOF
    Response.Write("<div align=center><Strong>"&events("Time")&": </Strong>"&events("GameDesc")&"")
    events.MoveNext
    Loop
    events.close
    Set events = Nothing    
                              %>


 
Old August 5th, 2004, 10:22 PM
Authorized User
 
Join Date: Mar 2004
Posts: 84
Thanks: 0
Thanked 0 Times in 0 Posts
Send a message via AIM to gmoney060 Send a message via MSN to gmoney060
Default

I keep going to the EOF..... I should have a entry to display....

 
Old August 6th, 2004, 02:44 AM
Friend of Wrox
 
Join Date: Sep 2003
Posts: 363
Thanks: 0
Thanked 1 Time in 1 Post
Default

Hello

events.Open "SELECT * FROM Events Where date=#" & date() & "#",ObjConn2,1,2

  in Access you query a date by "#" before and after date

 
Old August 7th, 2004, 02:22 AM
Friend of Wrox
 
Join Date: Jun 2003
Posts: 2,480
Thanks: 0
Thanked 1 Time in 1 Post
Default

Yes gmoney060, you should have an entry to display, only when you embed the date() with # on both side as suggested by RajaniKrishna.

It is always better to contruct your query on Access db first, and if that returns the expected result, then copy/paste that query in to your asp code (and make changes if required). That should always keep you out of trouble, than contructing sleect statements on the fly on asp page and searching for result set.

Hope that helps.
Cheers!

_________________________
- Vijay G
Strive for Perfection





Similar Threads
Thread Thread Starter Forum Replies Last Post
Using "now()" to save date and time to database misskaos Classic ASP Basics 12 October 11th, 2006 05:01 PM
Enter date to database Calverstine Dreamweaver (all versions) 0 August 8th, 2005 09:45 AM
Need Help Programming a Date Comparison Database jackson_jl Beginning VB 6 0 March 7th, 2005 03:03 PM
date problem with database umasankar ADO.NET 1 June 16th, 2004 11:58 PM
Unable to call the date from the database nvillare Classic ASP Basics 2 July 10th, 2003 04:44 PM





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