DateAdd Too few parameters. Expected 1 (1 Viewer)

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:40
Joined
May 7, 2009
Messages
19,246
of all the time, i have no clue.
thought you are executing it from ms access...
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:40
Joined
May 7, 2009
Messages
19,246
can you just add 30 (days) * 6 (month) = 180 days ?
or 365 \ 2 days = 182 days?
maybe it will work.


SELECT DateValue(DateOfCal)+182 AS NextCalibration FROM TblCalibItems;
 

jxwd

Member
Local time
Today, 08:40
Joined
Apr 6, 2022
Messages
35
sorry I did mention in my 3rd post... I wasn't sure if it was significant or not :) I assumed the drivers would "just" run it on Access ...
 

jxwd

Member
Local time
Today, 08:40
Joined
Apr 6, 2022
Messages
35
Yes success
SELECT DateValue(DateOfCal)+182 AS NextCal FROM TblCalibItems;

Things is I need to use another column (MonthsCal) for the integer number of months and sometimes may include Feb etc... so really need to use a function that can do all this accurately...
 

arnelgp

..forever waiting... waiting for jellybean!
Local time
Today, 15:40
Joined
May 7, 2009
Messages
19,246
just use Days (the Number of months converted to days) field.

can you try making a Public function and calling it in your Query:

Public Function DteAdd(ByVal dte As Variant, ByVal NoOfMonths As Integer) As Date
dte = DateValue(dte)
DteAdd = DateAdd("m", NoOfMonths, dte)
End Function

now try (if it will work):

SELECT DteAdd(DateOfCal, MonthsCal) AS NextCal FROM TblCalibItems;
 

jxwd

Member
Local time
Today, 08:40
Joined
Apr 6, 2022
Messages
35
Tried to declare the function (as a query)
[Microsoft][ODBC Microsoft Access Driver] Invalid SQL statement; expected 'DELETE', 'INSERT', 'PROCEDURE', 'SELECT', or 'UPDATE'.


It doesn't seem to like dateadd?

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
SELECT DATEADD ("month", -2, NOW()) AS NextCalibration FROM TblCalibItems;
 

jxwd

Member
Local time
Today, 08:40
Joined
Apr 6, 2022
Messages
35
And with "

[Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 2.
SELECT DATEADD ("day", -2, "{d '2022-02-02'}") AS NextCalibration FROM TblCalibItems;
 

cheekybuddha

AWF VIP
Local time
Today, 08:40
Joined
Jul 21, 2014
Messages
2,321
It looks like you are connecting to a MySQL backend. Is that so?

[Microsoft][ODBC Microsoft Access Driver] looks strange.

What version of MyODBC driver are you using?

Is it 32bit/64bit? Is it ANSI or unicode?

What version server are you using?
 

jxwd

Member
Local time
Today, 08:40
Joined
Apr 6, 2022
Messages
35
Connecting to MS Access, with ODBC driver.



SystemWindows NT PICWEB01 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) i586



odbc​

ODBC Supportenabled
Active Persistent Links0
Active Links0
ODBC libraryWin32
ODBCVER0x0350
DirectiveLocal ValueMaster Value
odbc.allow_persistentOnOn
odbc.check_persistentOnOn
odbc.default_cursortypeStatic cursorStatic cursor
odbc.default_dbno valueno value
odbc.default_pwno valueno value
odbc.default_userno valueno value
odbc.defaultbinmodereturn as isreturn as is
odbc.defaultlrlreturn up to 4096 bytesreturn up to 4096 bytes
odbc.max_linksUnlimitedUnlimited
odbc.max_persistentUnlimitedUnlimited
 

cheekybuddha

AWF VIP
Local time
Today, 08:40
Joined
Jul 21, 2014
Messages
2,321
What are you using as frontend? Access?

Why are you connecting Access -> Access using ODBC?
 

jxwd

Member
Local time
Today, 08:40
Joined
Apr 6, 2022
Messages
35
The front end is PHP. Because the IT company installed odbc drivers to interface with ACCESS... is there another way?
 

cheekybuddha

AWF VIP
Local time
Today, 08:40
Joined
Jul 21, 2014
Messages
2,321
I don't know whether DateAdd() is available in Access SQL - it is a VBA function that might not be accessible when accessing via ODBC.

Just grab the date as it appears in the record and process in php.
 

cheekybuddha

AWF VIP
Local time
Today, 08:40
Joined
Jul 21, 2014
Messages
2,321
Do you have direct access to the Access backend?

If so, perhaps create a saved query that uses the DateAdd() function and just select from the query.
 

jxwd

Member
Local time
Today, 08:40
Joined
Apr 6, 2022
Messages
35
yes I can get access to the backend if I need... but I have never used it.
 

jxwd

Member
Local time
Today, 08:40
Joined
Apr 6, 2022
Messages
35
NB this is a temporary solution... The next phase is to remove Access... and replace with mySQL
 

Users who are viewing this thread

Top Bottom