Web Wiz - Green Windows Web Hosting

  New Posts New Posts RSS Feed - Date problem
  FAQ FAQ  Forum Search   Events   Register Register  Login Login

Date problem

 Post Reply Post Reply
Author
Ignorance View Drop Down
Newbie
Newbie


Joined: 23 February 2003
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ignorance Quote  Post ReplyReply Direct Link To This Post Topic: Date problem
    Posted: 07 May 2003 at 6:24pm

Having a brainfart here. Any idea why I can't get the query to match dates? If I remove the date from the end of the query it works fine. I just can't seem to find why it won't match the date with the date field in the database. No matter what it always writes a new record. Here's the code.

dim rsh*t

dim conHit

dim strHitIP

dim strExtradata

dim dHitdate

dim strHitdbpath

dim strHitsql

strHitIP = trim(Request.ServerVariables("REMOTE_ADDR"))

strExtradata = trim(Request.ServerVariables("ALL_HTTP"))

dHitdate = cdate(month(now()) & "/" & day(now()) & "/" & year(now()))

 

set conHit = server.CreateObject("ADODB.Connection")

set rsh*t = server.CreateObject("ADODB.Recordset")

with rsh*t

.CursorType = 2

.LockType = 3

end with

 

strHitdbpath = server.MapPath("/forum/admin/database/hitcount.mdb")

conHit.ConnectionString = "Provider=Microsoft.Jet.OLEDB.4.0; Data Source=" & strHitdbpath 'This one is for Access 2000/2002

conHit.Open

strHitsql = "SELECT tblHit.* FROM tblHit WHERE tblHit.Hit_IP='"

strHitsql = strHitsql & strHitIP & "' AND tblHit.Hit_date=" & dHitdate & ";"

rsh*t.Open strHitsql, conHit

if rsh*t.EOF and rsh*t.BOF then

with rsh*t

.AddNew

.Fields("Hit_IP") = strHitIP

.Fields("Hit_data") = strExtradata

.Fields("Hit_date") = dHitdate

.Update

end with

end if

rsh*t.Close

set rsh*t = nothing

conHit.Close

set conHit = nothing

Any and all help appreciated.

Also, I get no errors from this code at all.



Edited by Ignorance
Back to Top
MorningZ View Drop Down
Senior Member
Senior Member
Avatar

Joined: 06 May 2002
Location: United States
Status: Offline
Points: 1793
Post Options Post Options   Thanks (0) Thanks(0)   Quote MorningZ Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 2003 at 7:38pm

i'll start by pointing out that instead of

dHitdate = cdate(month(now()) & "/" & day(now()) & "/" & year(now()))

you can just say:

dHitdate = Date()

Contribute to the working anarchy we fondly call the Internet
Back to Top
Ignorance View Drop Down
Newbie
Newbie


Joined: 23 February 2003
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ignorance Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 2003 at 8:35pm

Yes, much more compact that way. Not real proficient in VBScript. I miss my friend "Format" from VB, it had so many simple uses.

Cmon now, someone has got to have some experience with the way Access handles dates?

Back to Top
Ignorance View Drop Down
Newbie
Newbie


Joined: 23 February 2003
Status: Offline
Points: 28
Post Options Post Options   Thanks (0) Thanks(0)   Quote Ignorance Quote  Post ReplyReply Direct Link To This Post Posted: 07 May 2003 at 11:54pm

After spending the majority of the night looking I finally found an answer for my problem. So here it is for anyone else that needs it.

"since access uses a serial date format, you may need to enclose the date in the number/pound sign, ex: #01/10/03#"

Back to Top
 Post Reply Post Reply

Forum Jump Forum Permissions View Drop Down

Forum Software by Web Wiz Forums® version 12.08
Copyright ©2001-2026 Web Wiz Ltd.


Become a Fan on Facebook Follow us on X Connect with us on LinkedIn Web Wiz Blogs
About Web Wiz | Contact Web Wiz | Terms & Conditions | Cookies | Privacy Notice

Web Wiz is the trading name of Web Wiz Ltd. Company registration No. 05977755. Registered in England and Wales.
Registered office: Web Wiz Ltd, Unit 18, The Glenmore Centre, Fancy Road, Poole, Dorset, BH12 4FB, UK.

Prices exclude VAT at 20% unless otherwise stated. VAT No. GB988999105 - $, € prices shown as a guideline only.

Copyright ©2001-2026 Web Wiz Ltd. All rights reserved.