SQL Development
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
 
 
User Name:
Password:
Remember me
Go Back   ASP Free ForumsDatabaseSQL Development

Reply
Add This Thread To:
  Del.icio.us   Digg   Google   Spurl   Blink   Furl   Simpy   Y! MyWeb 
Thread Tools Search this Thread Rate Thread Display Modes
 
Unread ASP Free Forums Sponsor:
  #1  
Old April 6th, 2004, 07:26 PM
Jaiyan Jaiyan is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 4 Jaiyan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Date related question

Hi all,

Just a quick question. I'm trying to do a select statement that takes all records that have been created in my MS Access database within the last 3 days, but I'm having a few problems. I've done SQL statements using dates before, however never using the current date dynamically.

Currently, I have a field in the database called "date" with the structure DD/MM/YYYY, and I read somewhere that I should call the Date() inside the ASP script that I'm working on to get the current date. However, I don't seem to be any closer to getting it working.

Does anyone have any experience of this, and could point me in the right direction?

Thanks,
Jaiyan

Reply With Quote
  #2  
Old April 6th, 2004, 08:30 PM
Memnoch's Avatar
Memnoch Memnoch is offline
Unholy Moderator
ASP Free God 14th Plane (11500 - 11999 posts)
 
Join Date: Oct 2003
Location: In hell, where did you think?
Posts: 11,776 Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level)Memnoch User rank is Lieutenant Colonel (40000 - 50000 Reputation Level) 
Time spent in forums: 3 Weeks 5 Days 8 h 27 m 42 sec
Reputation Power: 470
Code:
SELECT *
FROM TableName
WHERE [dateField] >= DateAdd("d",-3, Now())

date is a reserved word in access. You should change the name of the field to something else.

Reply With Quote
  #3  
Old April 7th, 2004, 07:15 AM
Jaiyan Jaiyan is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 4 Jaiyan User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Ahh excellent. Now() it is. I was wondering why Date() wasn't working
And thanks for the tip about my date field, I'd better work on that too.

Thanks again
Jaiyan

Reply With Quote
  #4  
Old April 7th, 2004, 04:36 PM
aiyong04 aiyong04 is offline
Registered User
ASP Free Newbie (0 - 499 posts)
 
Join Date: Apr 2004
Posts: 3 aiyong04 User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
Unhappy Date problem

Dear all,

tempLastDate = DateValue(Session("LastLoginDate"))
SQL = "SELECT count(*) as DateMatch FROM tblLogin WHERE DateLogin > '"&tempLastDate&"'"
Set rsNotice = connNotice.Execute(SQL) //line 19

//the value of session("lastLoginDate") is 04/04/2004, dd/mm/yyyy, data type is date/time in microsoft access.
//connNotice is just a object connection
//tblLogin is a table, DateLogin contains date value which in dd/mm/yyyy format.

Error Type:
Microsoft OLE DB Provider for ODBC Drivers (0x80040E07)
[Microsoft][ODBC Microsoft Access Driver] Data type mismatch in criteria expression.
/project/Code/Home.asp, line 19

Are you have clue how to solve this problem???

thanks.

Reply With Quote
Reply

Viewing: ASP Free ForumsDatabaseSQL Development > Date related question


Thread Tools  Search this Thread 
Search this Thread:

Advanced Search
Display Modes  Rate This Thread 
Rate This Thread:


Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

vB code is On
Smilies are On
[IMG] code is On
HTML code is Off
View Your Warnings | New Posts | Latest News | Latest Threads | Shoutbox
Forum Jump


Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
  
 





© 2003-2008 by Developer Shed. All rights reserved. DS Cluster 1 hosted by Hostway
Stay green...Green IT