473,511 Members | 12,087 Online
Bytes | Software Development & Data Engineering Community
+ Post

Home Posts Topics Members FAQ

Using DateAdd with ODBC drivers

1 New Member
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 8049
isladogs
457 Recognized Expert Moderator Contributor
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 Recognized Expert Moderator Expert
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
457 Recognized Expert Moderator Contributor
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
214 Recognized Expert New Member
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,557 Recognized Expert Moderator MVP
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
23762
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
1377
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
7325
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
8704
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
1238
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
2661
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
8499
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
40322
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
2769
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
7245
marktang
by: marktang | last post by:
ONU (Optical Network Unit) is one of the key components for providing high-speed Internet services. Its primary function is to act as an endpoint device located at the user's premises. However,...
0
7144
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
7356
Oralloy
by: Oralloy | last post by:
Hello folks, I am unable to find appropriate documentation on the type promotion of bit-fields when using the generalised comparison operator "<=>". The problem is that using the GNU compilers,...
0
5671
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
5069
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
4741
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
3227
by: TSSRALBI | last post by:
Hello I'm a network technician in training and I need your help. I am currently learning how to create and manage the different types of VPNs and I have a question about LAN-to-LAN VPNs. The...
0
3214
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
1577
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

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.