Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17

x
?
Solved

Access append query receiving ODBC error

Posted on 2013-01-01
3
Medium Priority
?
599 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
[X]
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
  • 2
3 Comments
 
LVL 9

Accepted Solution

by:
keyu earned 2000 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

New benefit for Premium Members - Upgrade now!

Ready to get started with anonymous questions today? It's easy! Learn more.

Question has a verified solution.

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

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.
Ever visit a website where you spotted a really cool looking Font, yet couldn't figure out which font family it belonged to, or how to get a copy of it for your own use? This article explains the process of doing exactly that, as well as showing how…
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…
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…

688 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