|
|
|||||||||
|
|||||||||
| |||||||||
|
|
|
| |||||||||
![]() |
|
|
«
Previous Thread
|
Next Thread
»
|
Thread Tools | Search this Thread | Rate Thread | Display Modes |
|
|
|
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
|
|||
|
|||
|
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 |
|
#2
|
|||
|
|||
|
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 |
|
#3
|
|||
|
|||
|
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 |
|
#4
|
|||
|
|||
|
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 |
![]() |
| Viewing: Dev Shed Forums > Programming Languages - More > ASP Programming > sorting data by date |
| Thread Tools | Search this Thread |
| Display Modes | Rate This Thread |
|
|
|
|