Print Page | Close Window

Date problem

Printed From: Web Wiz Forums
Category: General Discussion
Forum Name: Classic ASP Discussion
Forum Description: Discussion on Active Server Pages (Classic ASP).
URL: https://forums.webwiz.net/forum_posts.asp?TID=2493
Printed Date: 29 March 2026 at 4:17pm
Software Version: Web Wiz Forums 12.08 - https://www.webwizforums.com


Topic: Date problem
Posted By: Ignorance
Subject: Date problem
Date 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.




Replies:
Posted By: MorningZ
Date 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


Posted By: Ignorance
Date 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?



Posted By: Ignorance
Date 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#"




Print Page | Close Window

Forum Software by Web Wiz Forums® version 12.08 - https://www.webwizforums.com
Copyright ©2001-2026 Web Wiz Ltd. - https://www.webwiz.net