Solved

Access append query receiving ODBC error

Posted on 2013-01-01
3
591 Views
Last Modified: 2013-01-14
I have a series of append queries that suddendly do not work.  I am receiving an ODBC error  ( attached).
I have been struggling with figuring this out. I have tested that tables - run independent queries on the tables... all ok.

It seemes when I take the "cint(mid(charted_date,5,2)) AS MONTH, cint(mid(charted_date,1,4)) AS Year"  out of the SQL it works.   The purpose of this satement is to take the date form of yyyymmdd and just take out the mm and the yy to apend to the table.



INSERT INTO MAK_SAVES
SELECT SITE AS SITE, MONTH AS [MONTH], YEAR AS [YEAR], LOCATION AS LOCATION, 1 AS ERROR, Count(*) AS TOTAL
FROM (SELECT DISTINCT PHM_MAC_ERR_DTL.SITE, PHM_MAC_ERR_DTL.LOCATION, PHM_MAC_ERR_DTL.CHARTED_TIME AS rounded, PHM_MAC_ERR_DTL.PAT_NUM, charted_date, NURSE_ID, cint(mid(charted_date,5,2)) AS MONTH, cint(mid(charted_date,1,4)) AS Year, 1 AS ERROR1, 0 AS ERROR2, 0 AS ERROR3, 0 AS ERROR4
FROM PHM_MAC_ERR_DTL
WHERE SITE in ("1","2","3")
AND  PHM_MAC_ERR_DTL.CHARTED_DATE between MonthRelToday(-1) and MonthRelToday(0)
AND (PHM_MAC_ERR_DTL.ERROR_CODE ="47")
)  AS [%$##@_Alias]
GROUP BY SITE, Month, Year, LOCATION;




Is there an alternate to  " cint(mid(charted_date,5,2)) AS MONTH, cint(mid(charted_date,1,4)) AS Year"


Thanks
EE-ODBC-ERROR.doc
0
Comment
Question by:joylene6
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
keyu earned 500 total points
ID: 38735695
Hi,

see if you wants to retrieve month and year from date no need to go for such a long path....

so insted of

cint(mid(charted_date,5,2)) AS MONTH, cint(mid(charted_date,1,4)) AS Year

use below might helps you...

month(charted_date) as month,year(charted_date) as year


for more references you can also refer below links....

http://www.databasedev.co.uk/retreive_date_query.html
0
 
LVL 1

Author Comment

by:joylene6
ID: 38774936
I did try this and it partially worked. I ened up changing quite alot of things in the code and getting it to work
0
 
LVL 1

Author Closing Comment

by:joylene6
ID: 38774939
Thanks - this did patrtially work and help me find my end solution. Thank you
0

Featured Post

DevOps Toolchain Recommendations

Read this Gartner Research Note and discover how your IT organization can automate and optimize DevOps processes using a toolchain architecture.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

PL/SQL can be a very powerful tool for working directly with database tables. Being able to loop will allow you to perform more complex operations, but can be a little tricky to write correctly. This article will provide examples of basic loops alon…
Lync meeting or Lync conferencing is what many organizations would like to deploy to allow them save money. But companies are now giving up for various reasons, one of which is that they cannot join external meetings (non-federated company meetings)…
The view will learn how to download and install SIMTOOLS and FORMLIST into Excel, how to use SIMTOOLS to generate a Monte Carlo simulation of 30 sales calls, and how to calculate the conditional probability based on the results of the Monte Carlo …
The viewer will learn how to use a discrete random variable to simulate the return on an investment over a period of years, create a Monte Carlo simulation using the discrete random variable, and create a graph to represent the possible returns over…

809 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question