ASP Date/Time Variables

Discussion in 'ASP General' started by dmiller23462, Jul 28, 2004.

  1. dmiller23462

    dmiller23462 Guest

    Hey guys,

    I'm back again....

    I'm trying to put together a search page but what I'm trying to pull
    off is only showing the past week's entries....

    I've tried declaring "pastweek" as a variable that is actually the
    Now() variable....I can't seem to find any syntax help....Basically I
    was thinking something along the lines of Now() - 7 days or Now() - 1
    week....however I can do that....

    I also tried DateAdd("d", -7, pastweek) but I'm not completely sure
    how to put that into the SQL statement without returning any
    errors....I am missing an operator somewhere in the statement and I'm
    getting a bit flustered....I asked our resident SQL statement expert
    and he even tried a few things to no avail....

    Let me know what YOU would do in the situation...

    snippet of my SQL statement follows;
    SQLqry = "SELECT * FROM shortage where date <= " & pastweek
     
    dmiller23462, Jul 28, 2004
    #1
    1. Advertising

  2. dmiller23462

    Jeff Cochran Guest

    On 28 Jul 2004 05:19:30 -0700, (dmiller23462)
    wrote:

    >I'm trying to put together a search page but what I'm trying to pull
    >off is only showing the past week's entries....
    >
    >I've tried declaring "pastweek" as a variable that is actually the
    >Now() variable....I can't seem to find any syntax help....Basically I
    >was thinking something along the lines of Now() - 7 days or Now() - 1
    >week....however I can do that....
    >
    >I also tried DateAdd("d", -7, pastweek) but I'm not completely sure
    >how to put that into the SQL statement without returning any
    >errors....I am missing an operator somewhere in the statement and I'm
    >getting a bit flustered....I asked our resident SQL statement expert
    >and he even tried a few things to no avail....
    >
    >Let me know what YOU would do in the situation...
    >
    >snippet of my SQL statement follows;
    >SQLqry = "SELECT * FROM shortage where date <= " & pastweek


    Might start with:

    Could I get a little help with dates?
    http://www.aspfaq.com/show.asp?id=2040

    Jeff
     
    Jeff Cochran, Jul 28, 2004
    #2
    1. Advertising

  3. dmiller23462

    dmiller23462 Guest

    I got it working....The correct syntax that has worked for me is as follows;

    **start snippet**
    SQLqry = "SELECT * FROM shortage WHERE date >= " & "DateAdd('d', -7, Now())"
    **stop snippet**

    (Jeff Cochran) wrote in message news:<>...
    > On 28 Jul 2004 05:19:30 -0700, (dmiller23462)
    > wrote:
    >
    > >I'm trying to put together a search page but what I'm trying to pull
    > >off is only showing the past week's entries....
    > >
    > >I've tried declaring "pastweek" as a variable that is actually the
    > >Now() variable....I can't seem to find any syntax help....Basically I
    > >was thinking something along the lines of Now() - 7 days or Now() - 1
    > >week....however I can do that....
    > >
    > >I also tried DateAdd("d", -7, pastweek) but I'm not completely sure
    > >how to put that into the SQL statement without returning any
    > >errors....I am missing an operator somewhere in the statement and I'm
    > >getting a bit flustered....I asked our resident SQL statement expert
    > >and he even tried a few things to no avail....
    > >
    > >Let me know what YOU would do in the situation...
    > >
    > >snippet of my SQL statement follows;
    > >SQLqry = "SELECT * FROM shortage where date <= " & pastweek

    >
    > Might start with:
    >
    > Could I get a little help with dates?
    > http://www.aspfaq.com/show.asp?id=2040
    >
    > Jeff
     
    dmiller23462, Jul 28, 2004
    #3
    1. Advertising

Want to reply to this thread or ask your own question?

It takes just 2 minutes to sign up (and it's free!). Just click the sign up button to choose a username and then you can ask your own questions on the forum.
Similar Threads
  1. Chris Berg
    Replies:
    0
    Views:
    806
    Chris Berg
    Oct 27, 2003
  2. Peter Grison

    Date, date date date....

    Peter Grison, May 28, 2004, in forum: Java
    Replies:
    10
    Views:
    3,300
    Michael Borgwardt
    May 30, 2004
  3. Keith Cochrane
    Replies:
    2
    Views:
    630
    Keith Cochrane
    Aug 6, 2006
  4. flamesrock
    Replies:
    8
    Views:
    502
    Hendrik van Rooyen
    Nov 24, 2006
  5. Summu82
    Replies:
    5
    Views:
    877
    Richard Heathfield
    Jun 7, 2006
Loading...

Share This Page