472,958 Members | 2,309 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 472,958 software developers and data experts.

Using DateAdd with ODBC drivers

1
Hi I have tried all kinds of formats and syntax I just can't get DateAdd to work with ODBC drivers...

System Windows NT PICWEB01 6.3 build 9600 (Windows Server 2012 R2 Standard Edition) i586
ODBC library Win32
ODBCVER 0x0350

EG

Expand|Select|Wrap|Line Numbers
  1. [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
  2. SELECT DATEADD ("dd", -2, '#1969-12-31 20:00:00#') AS NextCalibration FROM TblCalibItems;
Expand|Select|Wrap|Line Numbers
  1. [Microsoft][ODBC Microsoft Access Driver] Too few parameters. Expected 1.
  2. SELECT DATEADD ("second", -2, '2022-02-02') AS NextCalibration FROM TblCalibItems;
etc...
Apr 14 '22 #1
5 7880
isladogs
443 Expert Mod 256MB
Perhaps I've got this wrong but it appears that you are writing this code in Access
If so, try

Expand|Select|Wrap|Line Numbers
  1. SELECT DATEADD ("d", -2, "#1969-12-31 20:00:00#") AS NextCalibration FROM TblCalibItems;
and
Expand|Select|Wrap|Line Numbers
  1. SELECT DATEADD ("s", -2, "#2022-02-02#") AS NextCalibration FROM TblCalibItems;
Apr 14 '22 #2
zmbd
5,501 Expert Mod 4TB
What is your backend?
What is your frontend?
The syntax can be quite specific to what FE and BE you are using... as seen here starting around post6:

home > topics > asp / active server pages > questions > dateadd in sql statement not working (Post#6)


[Edit] Did not see isladogs post to your question until after I had made mine due to it being in moderation status.; however, it follows along the same line as the thread I linked you to... syntax is everything :)
Apr 14 '22 #3
isladogs
443 Expert Mod 256MB
Thanks @zmbd
I approved the OP's post but for some reason was unable to get my own reply to appear!
Apr 15 '22 #4
cactusdata
210 Expert 128KB
DATEADD is not field of your table but a function, so try:

Expand|Select|Wrap|Line Numbers
  1. SELECT DateAdd("d", -2, "#1969-12-31 20:00:00#") AS NextCalibration FROM TblCalibItems;
Also, the correct arguments for DateAdd are required: DateAdd function.
Apr 15 '22 #5
NeoPa
32,547 Expert Mod 16PB
I would point you towards a few issues with your tests. Some have previously been identified / hinted at already.

Jet/ACE SQL allows both the appropriate SQL format quotes (') as well as the double-quotes ("). Mixing them, as you have, is probably also perfectly acceptable - even if it does look confused.

Acceptable values for the Interval parameter are listed in the article Cactus linked you to. Neither of "dd" nor "second" is in that list.

Some versions of SQL (T-SQL being an example) don't allow for date literal values and require a properly formatted date string (In such cases they require proper SQL quotes (') as delimiters). Access supports the same DateTime literals in SQL as it does in VBA. These require DateTime (Hash or Octothorp #) indicators and do not require string quotes, of any variety, around them. For more on what is acceptable for DateTimes see Literal DateTimes and Their Delimiters (#). You'll see there that your date formatting is otherwise optimal. Probably the best of the available standard SQL formats for them. Certainly the one with the least possibility of ambiguity.

I think, between us, we've explained every problem illustrated in your SQL code. I would just add, before I stop, my congratulations for formatting your question such that all the relevant information was available to us at the start.
Apr 15 '22 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

2
by: paul tomlinson | last post by:
Hi folks - i've got a windows 2000 server (SP3) i've run the IIS lockdown tool on it and set for dynamic websites - all the static pages within the site work ok but an ASP section has been put in...
15
by: M P | last post by:
What does this mean? I am accessing an ASP page that queries Access Database thru fileDSN. I'm using IIS 5.0 Win2K SP4 Microsoft OLE DB Provider for ODBC Drivers error '80004005' General...
2
by: john_20_28_2000 | last post by:
They are corrupt. I cannot get the odbc driver applet for sql server to open when I click add and I cannot configure any existing ones. And the usage of the drivers fail. Other ODBC drivers...
1
by: MLH | last post by:
I'm running XP. Is it required that a given ODBC driver be selected or set somehow as a default driver? Look at this... Here's the error: Error: ODBC call failed... Datasource not found and no...
0
by: Mark | last post by:
Hi all, I was wondering if anybody knew if it was at all possible to install old odbc drivers (approx ver 3.5) instead of the standard windows XP (ver 4.0)? The reason I need to use 3.5 is because...
4
by: hugh welford | last post by:
Hi - using XP pro with IIS to develop offline asp data access site. Suddenly, my DSNs and odbc drivers have disappeared - the only thing I can think of is that an XP auto update has done this in...
2
by: pericpero | last post by:
Hi There seem to be a number of posts already with this error message but none of them have helped me ... I am trying to execute some dynamic SQL from an ASP form to update or delete from a...
4
by: ToddAndMargo | last post by:
Hi All, Okay. I give up. I need to install the latest ODBC drivers that work with Microsoft's SQL server 2000. (I am write a Lotus Approach front end to an existing sql2000 database.) I...
1
by: jimbo905 | last post by:
My secretaries HD crashed - bummer. I got a new HD running XP pro with SP3. I have installed 8i client using the OUI (at first I had to rename symcjit.dll to symcjit_old.dll). All the components...
0
by: lllomh | last post by:
Define the method first this.state = { buttonBackgroundColor: 'green', isBlinking: false, // A new status is added to identify whether the button is blinking or not } autoStart=()=>{
2
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 4 Oct 2023 starting at 18:00 UK time (6PM UTC+1) and finishing at about 19:15 (7.15PM) The start time is equivalent to 19:00 (7PM) in Central...
0
by: Aliciasmith | last post by:
In an age dominated by smartphones, having a mobile app for your business is no longer an option; it's a necessity. Whether you're a startup or an established enterprise, finding the right mobile app...
3
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be using a very simple database which has Form (clsForm) & Report (clsReport) classes that simply handle making the calling Form invisible until the Form, or all...
1
by: Teri B | last post by:
Hi, I have created a sub-form Roles. In my course form the user selects the roles assigned to the course. 0ne-to-many. One course many roles. Then I created a report based on the Course form and...
0
isladogs
by: isladogs | last post by:
The next Access Europe meeting will be on Wednesday 1 Nov 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM) Please note that the UK and Europe revert to winter time on...
3
by: nia12 | last post by:
Hi there, I am very new to Access so apologies if any of this is obvious/not clear. I am creating a data collection tool for health care employees to complete. It consists of a number of...
0
NeoPa
by: NeoPa | last post by:
Introduction For this article I'll be focusing on the Report (clsReport) class. This simply handles making the calling Form invisible until all of the Reports opened by it have been closed, when it...
0
isladogs
by: isladogs | last post by:
The next online meeting of the Access Europe User Group will be on Wednesday 6 Dec 2023 starting at 18:00 UK time (6PM UTC) and finishing at about 19:15 (7.15PM). In this month's session, Mike...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.