pulling the data from the last 30 days

Results 1 to 4 of 4

Thread: pulling the data from the last 30 days

  1. #1
    comb Guest

    Default pulling the data from the last 30 days

    hey everyone, i hope i don&#039t get shot for answering this question, but i can&#039t seem to dig up the answer.<BR><BR>i&#039m creating a normal news posting app where i can post "news" to an Access database and then have everyone view them. the problem i am encountering happens when i am trying to pull the last month&#039s worth.<BR><BR>at the moment, i have a workaround where i pull all the articles from the current month and year (eg dec 1-26) and not from the past 31 days (nov26-dec 26) ..i&#039ve tried a few things with parsing strings and such, but then realized that the way i&#039ve got the sql statement set up, i can&#039t feed a "date" string into it and expect it to be able to compare to the date column in the database. now if i try to compare strings, i think the results would be absurd. here&#039s a look at my sql statement:<BR><BR>```````````````````````````````` ```````````````````````````````<BR>Sub PullPrior31Days<BR> currDate = Now()<BR> oneMonthAgo = DateAdd("m", -1, currDate)<BR> Response.Write(temp & "&#060;brtag&#062;&#060;brtag&#062;")<BR> Response.Write(VarType(temp)& "&#060;brtag&#062;&#060;brtag&#062;")<BR> &#039 PROBLEM: mySQL stmnt is a string and i cannot have it<BR> &#039 compare within the string<BR> &#039 the date_time column with the onMonthAgo date variable<BR> &#039 value this means i have to look up another way to tell <BR> &#039 SQL to compare date VALUES and not strings<BR> mySQL = "SELECT * FROM news WHERE date_time &#062; oneMonthAgo ORDER BY date_time DESC"<BR>End Sub<BR>``````````````````````````````````````````` ``````````````````<BR><BR>where that &#039oneMonthAgo variable appears in the sql statement is the source of my confusion. i&#039ve tried to concatonate it and then realized my error. i&#039m terribly new to SQL and ASP, so i do not yet know of a way to explicitly issue a command to have SQL compare the DATE var inside my VBScript with a DATE value in the Access Database<BR><BR>any ideas? thanks in advance for anyhelp!<BR>comb<BR>combhua@tamu.edu

  2. #2
    Eddie Campbell Guest

    Default RE: pulling the data from the last 30 days

    You need to put the oneMonthAgo variable into the SQL string. As you are using Access, you also need to surround it with # marks. See below.<BR><BR>Sub PullPrior31Days<BR>currDate = Now()<BR>oneMonthAgo = DateAdd("m", -1, currDate)<BR>mySQL = "SELECT * FROM news WHERE date_time &#062; #" & oneMonthAgo & "# ORDER BY date_time DESC"<BR>End Sub<BR>

  3. #3
    comb Guest

    Default THANKS! - also wanna recommend a good ASP referenc

    WOOOOHOOOO!!<BR> thanks :)<BR><BR>i REALLY need to pick up a large ASP reference. the sites that i have found online seem to have several varying ways to do things and when i try to combine them, i ALWAYS run into darn problems. probably gonna goto barnes and noble tomorrow.. got any suggestions for a good ASP reference book?

  4. #4
    J. Paul Schmidt Guest

    Default RE: THANKS! - also wanna recommend a good ASP refe

    Here are a couple great ASP books:<BR><BR>1) Visual InterDev 6 Unleashed by Paul Thurrott... Sams (It&#039s got a lot of great reference material such as keywords for VBScript, JavaScript, HTML...)<BR><BR>2) Active Server Pages 2.0 Unleashed by Stephen Walther... Sams<BR><BR>Best regards,<BR>-Paul<BR><BR>J. Paul Schmidt, MBA<BR>Databases on the Web<BR>http://www.Bullschmidt.com<BR><BR>

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts