This is what I have ended up with...
function MM_Validate()
{
strError = "There appears to be a problem with some of the data you input:\n\n"
var yearToCheck = document.formproject01.completedateyy.value;
var monthToCheck = document.formproject01.completedatemm.value - 1;
var dateToCheck =...
I have three listboxes for a date - day,month and year.
The day listbox has values 1-31
The Month listbox has values 1-12
The Year listbox has values 2005-2010
I concatonate these values and pass them to a database, so I have control over the format.
This works fine until you select...
DNG,
Thanks for the help. Bouncing the code around for a while was really useful. It sometimes helps just to get someone to confirm that you are not doing anything really silly.
OK, here is the answer!
the code:
v_comparedate = (Month(Date))&"/"&(Day(Date))&"/"&(Year(Date))
SQL = "SELECT * FROM Project Where CloseDate > #" & v_comparedate & "#;"
The result:
it works!
Therefor:
Everything is stored correctly in access in dd/mm/yyyy format.
When you use...
STOP PRESS!
I know why it is not working:
Although the date is stored in access as dd/mm/yyyy it is still being passed back to the ASP page as mm/dd/yyyy.
I found this out by hard coding the date into the SQl string:
the code:
SQL = "SELECT * FROM Project Where CloseDate > #06/06/2005#;"...
Yep, I'm afraid I've already tried it. I will double check though just in case...
...nope, still fails to weed out those future dates.
There is something very screwy going on here. I just can't understand why the dates appear to be being compared as strings rather than dates.
Hmmm, It looks like Access doesn't support the convert function:
Microsoft JET Database Engine (0x80040E14)
Undefined function 'CONVERT' in expression.
It looks as though it is interpreting the 'dd' part of the date first and obviously thinks that '29' is greater than '02'.
OK but that still...
Just as an aside, I am using the driver:
Connection = "PROVIDER=Microsoft.Jet.OLEDB.4.0;" & "Data Source=" & Server.MapPath("/cands/database/project.mdb")
I have also tested it with the ODBC driver and it produces the same result.
OK,
This is the code that I am now using to check:
SQL = "SELECT * FROM Project Where CloseDate > #"& Now() &"#;"
response.Write("date = ")
response.Write(date)
response.Write("<br>")
response.Write("SQL = ")
response.Write(SQL)
The output I get is:
date = 02/06/2005
SQL = SELECT * FROM...
Hmmm, I have just ried that and it still retrieve everything, regardless of the date.
The code now reads:
SQL = "SELECT * FROM Project Where CloseDate > #"& Now() &"#;"
I am building a web site in ASP using MS Access as the database (for the time being)
I excecute the following SQL query to retrieve records that are still 'open' (e.g the CloseDate must be in the future)
SQL = "SELECT * FROM Project Where CloseDate > #" & Date() & "#;"
This statement returns...
This site uses cookies to help personalise content, tailor your experience and to keep you logged in if you register.
By continuing to use this site, you are consenting to our use of cookies.