Solved

Access append query receiving ODBC error

Posted on 2013-01-01
3
588 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

Backup Your Microsoft Windows Server®

Backup all your Microsoft Windows Server – on-premises, in remote locations, in private and hybrid clouds. Your entire Windows Server will be backed up in one easy step with patented, block-level disk imaging. We achieve RTOs (recovery time objectives) as low as 15 seconds.

Join & Write a Comment

Suggested Solutions

We were having a lot of "Heartbeat Alerts" in our SCOM environment, now "Heartbeat" in a SCOM environment for those of you who might not be familiar with SCOM is a packet of data sent from the agent to the management server on a regular basis, basic…
This article describes how to use the timestamp of existing data in a database to allow Tableau to calculate the prior work day instead of relying on case statements or if statements to calculate the days of the week.
Viewers will learn the different options available in the Backstage view in Excel 2013.
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 …

757 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

Need Help in Real-Time?

Connect with top rated Experts

20 Experts available now in Live!

Get 1:1 Help Now