Solved

Access append query receiving ODBC error

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

Free Tool: IP Lookup

Get more info about an IP address or domain name, such as organization, abuse contacts and geolocation.

One of a set of tools we are providing to everyone as a way of saying thank you for being a part of the community.

Question has a verified solution.

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

I'm trying, I really am. But I've seen so many wrong approaches involving date(time) boundaries I despair about my inability to explain it. I've seen quite a few recently that define a non-leap year as 364 days, or 366 days and the list goes on. …
Having trouble getting your hands on Dynamics 365 Field Service or Project Service trial? Worry No More!!!
The viewer will learn how to create a normally distributed random variable in Excel, use a normal distribution to simulate the return on an investment over a period of years, Create a Monte Carlo simulation using a normal random variable, and calcul…
The viewer will learn how to create two correlated normally distributed random variables in Excel, use a normal distribution to simulate the return on different levels of investment in each of the two funds over a period of ten years, and, create a …

820 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