SELECT DateDiff("n", LastDate, Now()) as datediffs FROM UserLog WHERE ID = 1
When I execute this query from Query Design View (MS Access). This give me different in minutes well like this:
datediffs --------- 2826
But when I execute the same query (including static value in where condition ID = 1) from servlet like this:
strSql = "SELECT DateDiff(\"n\", LastDate, Now()) as datediffs FROM UserLog WHERE ID = 1";
recset=stmt.executeQuery(strSql);
It gives me the following error:
[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected
1.
So what wrong with me?
Write-up of comments from above.
If
runs, then you need to look at the various other parts of your statement. For example, Now() can cause a problem if the database has lost references.
However, you report
Which is odd, because DateDiff notmally works outside of MS Access. However, I notice that this problem is reported in Oracle Bugs. In the comments, one person mentions that in his or her case, the problem was a misnamed column, so it may be possible to use ACE, rather than Jet for the connection. Alternatively, as you say, "get datediff in minutes from Java."