ASP Programming
 
Forums: » Register « |  User CP |  Games |  Calendar |  Members |  FAQs |  Sitemap |  Support | 
User Name:
Password:
Remember me
Go Back   Dev Shed ForumsProgramming Languages - MoreASP Programming

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 Dev Shed Forums Sponsor:
Get inside! Sample the range of functionality easily built with JMSL Library for Time Series Data Analysis, Heat Maps, Portfolio Optimization, Monte Carlo Simulation, Stock Price Charting and more. Download Now!
  #1  
Old July 31st, 2003, 10:31 AM
wesleyh wesleyh is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 4 wesleyh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
sorting data by date

Hi,

I'm trying to display data from a *.mdb database. I want to display new entries into the database within the last month. Currently the access database does not have a date field setup. Is ther anything special i have to call a field to store dates and also what command would i need to use to call only items that have a date within the last month. Currently to display data i use "SELECT * FROM FilmInfo ORDER BY FilmName ASC"
to pull data from the database.

Thanks

Wes

Reply With Quote
  #2  
Old July 31st, 2003, 12:16 PM
nopoints nopoints is offline
Contributing User
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jul 2003
Location: Windsor ON, Canada
Posts: 459 nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level)nopoints User rank is Corporal (100 - 500 Reputation Level) 
Time spent in forums: 13 h 44 m 22 sec
Reputation Power: 8
to store a date you need a Date/Time field. to get the current date (and time) use Now. to just get the date use Date, to just get the time use Time. other than that you can simply use boolean logic (greater than, less than, etc) in the WHERE clause.

also in the sql you must enclose a date in #. i.e.
Code:
"#" & Now & "#"
__________________
Programmer's Corner

Reply With Quote
  #3  
Old July 31st, 2003, 05:25 PM
wesleyh wesleyh is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 4 wesleyh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
so should i have something like this

"SELECT * FROM FilmInfo WHERE Added > DateAdd("m", 1,Date()) ORDER BY Added DESC"

I need to to use the DateAdd and Date() as i am trying to call records that are entered in the last month. The above is obviously wrong cos it doesn't work but i'm i on the right track and have you any tips where i'm going wrong in the above statement because i get the following error

Error Type:
Microsoft VBScript compilation (0x800A0401)
Expected end of statement
/list_new.asp, line 6, column 66
MovieList.Source = "SELECT * FROM FilmInfo WHERE Added > DateAdd("m", 1,Date()) ORDER BY Added DESC"
-----------------------------------------------------------------^

Just to save confusion, Added is the field that has the Date/Time field.

Wes

Reply With Quote
  #4  
Old August 1st, 2003, 11:03 AM
wesleyh wesleyh is offline
Junior Member
Dev Shed Newbie (0 - 499 posts)
 
Join Date: Jan 2003
Posts: 4 wesleyh User rank is Just a Lowly Private (1 - 20 Reputation Level) 
Time spent in forums: < 1 sec
Reputation Power: 0
solved it

thanks for your help. This was the statement i was looking for

"SELECT * FROM FilmInfo WHERE Added>DateAdd('m',-1,Date()) ORDER BY Added ASC"

It just took me a while to get the staement right without getting any expected end of statements.

Patients is a virtue


Wes

Reply With Quote
Reply

Viewing: Dev Shed ForumsProgramming Languages - MoreASP Programming > sorting data by date


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 5 hosted by Hostway