Ask a Question related to ASP Database, Design and Development.
-
Tom Jordan #1
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
-
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... -
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... -
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... -
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... -
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... -
Bob Barrows [MVP] #2
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
-
Tom Jordan #3
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
-
Tom Jordan #4
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
-
Evertjan. #5
Re: ASP - Access and dates
Tom Jordan wrote on 02 jul 2004 in microsoft.public.inetserver.asp.db:
Not true, [unless you store your dates in a textfield]> My Access DB is in dd/mm/yyyy format,
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
-
Bob Barrows [MVP] #6
Re: ASP - Access and dates
Tom Jordan wrote:
[url]http://www.aspfaq.com/show.asp?id=2313[/url] vbscript> 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=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



Reply With Quote

