ASP - Access and dates

Ask a Question related to ASP Database, Design and Development.

  1. #1

    Default ASP - Access and dates

    Hi All,

    Some suggestions with this would be appreciated.

    I have a page that gives customers the ability to retrieve records for
    the last 3 months, based on a DATEADDED column in my DB. I use a drop
    down menu with the past 3 months in it, which then self submits. The
    default is the current month.

    It works fine if I select the first month, for instance using May,
    June, July. If I select May it returns all the records for May. But
    anything else it just returns every single record for that customer!

    Here is a snippet:

    -------------
    customerid = request.cookies("validated_id")

    if request.form("month") = "" then
    BaseDate = date()
    strDatefrom = DateSerial(Year(BaseDate), Month(BaseDate) + iOffset, 1)

    BaseDate = date()
    strDateto = DateSerial(Year(BaseDate), Month(BaseDate) + 1, 0)

    else
    BaseDate = request.form("month")
    strDatefrom = DateSerial(Year(BaseDate), Month(BaseDate) + iOffset, 1)
    response.write DateSerial(Year(BaseDate), Month(BaseDate) + iOffset,
    1) & "<br>"

    BaseDate = request.form("month")
    strDateto = DateSerial(Year(BaseDate), Month(BaseDate) + 1, 0)
    end if

    strSQLquery = "SELECT * FROM unlocks WHERE dateadded BETWEEN #" &
    strDatefrom & "# AND #" & strDateto & "# AND customerid = '" &
    customerid & "' order by unlockid desc"
    Set rs = Server.CreateObject("ADODB.Recordset")
    rs.Open strSQLQuery, conn, 3, 3

    -------------------

    Thanks in advance guys! :)

    Tom
    Tom Jordan Guest

  2. Similar Questions and Discussions

    1. Between Dates
      I am trying to query an online access database and return records that have occurred between dates. I am using another query which does work to...
    2. ASP/VBS Dates Between Dates
      I'm trying to filter records depending on 2 dates requested from the querystring MMColParam1 (startdate) and MMColParam2 (enddate), i.e. a list...
    3. Access 2000 and Dates going wrong
      Hi, Can anyone tell me how to fix my date problem in MX2004 and Access 2000. I have a table where I am trying to only get records of a certain...
    4. Help with Dates please
      Hi, In a SQL table I have a field named departure and a date in inserted in it. What is the exact syntax to get only records with a future date...
    5. ASP & MS Access and Dates...
      Hi, I am fairly new to ASP so please forgive any possible stupidity. I have a series of ASP pages that read/write to an Access database. One...
  3. #2

    Default Re: ASP - Access and dates

    Use Response.Write to debug your SQL statement. This is the only way to find
    out what your database's query engine is seeing:

    Response.Write strSQLquery
    Response.End

    If the query is constructed correctly, you should be able to copy it to the
    clipboard from the browser window, open your database in Access, create a
    new query in Design View (closing the choose Tables dialog without selecting
    a table), paste the statement into SQL View window, and run it without
    modification. If it does not return the correct results, then you should use
    the Query Builder to create a query that does return the correct results and
    compare the two.

    If seeing the result from this response.write does not help you solve your
    problem, then show it to us. We cannot debug your code without seeing what's
    going into your code and what's coming out of it.

    Bob Barrows
    Tom Jordan wrote:
    > Hi All,
    >
    > Some suggestions with this would be appreciated.
    >
    > I have a page that gives customers the ability to retrieve records for
    > the last 3 months, based on a DATEADDED column in my DB. I use a drop
    > down menu with the past 3 months in it, which then self submits. The
    > default is the current month.
    >
    > It works fine if I select the first month, for instance using May,
    > June, July. If I select May it returns all the records for May. But
    > anything else it just returns every single record for that customer!
    >
    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

  4. #3

    Default Re: ASP - Access and dates

    thanks for the response Bob,

    I've figured out the problem - but can't fix it :(

    My Access DB is in dd/mm/yyyy format, my server is set to the same
    format and I have also used "Session.LCID = 3081" to set the date
    format.

    But, the SQL query will only accept mm/dd/yyyy format!

    If anyone has any suggestions then I would be v. grateful!

    Tom

    "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message news:<#bYyTu1XEHA.1684@tk2msftngp13.phx.gbl>...
    > Use Response.Write to debug your SQL statement. This is the only way to find
    > out what your database's query engine is seeing:
    >
    > Response.Write strSQLquery
    > Response.End
    >
    > If the query is constructed correctly, you should be able to copy it to the
    > clipboard from the browser window, open your database in Access, create a
    > new query in Design View (closing the choose Tables dialog without selecting
    > a table), paste the statement into SQL View window, and run it without
    > modification. If it does not return the correct results, then you should use
    > the Query Builder to create a query that does return the correct results and
    > compare the two.
    >
    > If seeing the result from this response.write does not help you solve your
    > problem, then show it to us. We cannot debug your code without seeing what's
    > going into your code and what's coming out of it.
    >
    > Bob Barrows
    > Tom Jordan wrote:
    > > Hi All,
    > >
    > > Some suggestions with this would be appreciated.
    > >
    > > I have a page that gives customers the ability to retrieve records for
    > > the last 3 months, based on a DATEADDED column in my DB. I use a drop
    > > down menu with the past 3 months in it, which then self submits. The
    > > default is the current month.
    > >
    > > It works fine if I select the first month, for instance using May,
    > > June, July. If I select May it returns all the records for May. But
    > > anything else it just returns every single record for that customer!
    > >
    Tom Jordan Guest

  5. #4

    Default Re: ASP - Access and dates

    For the record - I've found the answer.

    Apparently, the underlying SQL query engine is ALWAYS set to US
    format, and cannot be altered.

    I found a workaround at 4Guys:
    [url]http://www.4guysfromrolla.com/webtech/041001-1.2.shtml[/url]

    Tom

    "Bob Barrows [MVP]" <reb01501@NOyahoo.SPAMcom> wrote in message news:<#bYyTu1XEHA.1684@tk2msftngp13.phx.gbl>...
    > Use Response.Write to debug your SQL statement. This is the only way to find
    > out what your database's query engine is seeing:
    >
    > Response.Write strSQLquery
    > Response.End
    >
    > If the query is constructed correctly, you should be able to copy it to the
    > clipboard from the browser window, open your database in Access, create a
    > new query in Design View (closing the choose Tables dialog without selecting
    > a table), paste the statement into SQL View window, and run it without
    > modification. If it does not return the correct results, then you should use
    > the Query Builder to create a query that does return the correct results and
    > compare the two.
    >
    > If seeing the result from this response.write does not help you solve your
    > problem, then show it to us. We cannot debug your code without seeing what's
    > going into your code and what's coming out of it.
    >
    > Bob Barrows
    > Tom Jordan wrote:
    > > Hi All,
    > >
    > > Some suggestions with this would be appreciated.
    > >
    > > I have a page that gives customers the ability to retrieve records for
    > > the last 3 months, based on a DATEADDED column in my DB. I use a drop
    > > down menu with the past 3 months in it, which then self submits. The
    > > default is the current month.
    > >
    > > It works fine if I select the first month, for instance using May,
    > > June, July. If I select May it returns all the records for May. But
    > > anything else it just returns every single record for that customer!
    > >
    Tom Jordan Guest

  6. #5

    Default Re: ASP - Access and dates

    Tom Jordan wrote on 02 jul 2004 in microsoft.public.inetserver.asp.db:
    > My Access DB is in dd/mm/yyyy format,
    Not true, [unless you store your dates in a textfield]

    The dates are stored in an internal numeric value, independent of the in
    and outut format.

    The access PROGRAMME has it's own in- and output format, the database does
    not. So if you use an aspect database in an ASP environment, ysing the jet
    engine, you are not.

    --
    Evertjan.
    The Netherlands.
    (Please change the x'es to dots in my emailaddress)
    Evertjan. Guest

  7. #6

    Default Re: ASP - Access and dates

    Tom Jordan wrote:
    > thanks for the response Bob,
    >
    > I've figured out the problem - but can't fix it :(
    >
    > My Access DB is in dd/mm/yyyy format, my server is set to the same
    > format and I have also used "Session.LCID = 3081" to set the date
    > format.
    >
    > But, the SQL query will only accept mm/dd/yyyy format!
    >
    > If anyone has any suggestions then I would be v. grateful!
    >
    [url]http://www.aspfaq.com/show.asp?id=2313[/url] vbscript
    [url]http://www.aspfaq.com/show.asp?id=2040[/url] help with dates
    [url]http://www.aspfaq.com/show.asp?id=2260[/url] dd/mm/yyy confusion

    Bob Barrows

    --
    Microsoft MVP - ASP/ASP.NET
    Please reply to the newsgroup. This email account is my spam trap so I
    don't check it very often. If you must reply off-line, then remove the
    "NO SPAM"


    Bob Barrows [MVP] Guest

Posting Permissions

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

1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139