Tek-Tips is the largest IT community on the Internet today!

Members share and learn making Tek-Tips Forums the best source of peer-reviewed technical information on the Internet!

  • Congratulations Chriss Miller on being selected by the Tek-Tips community for having the most helpful posts in the forums last week. Way to Go!

Date Function in MS Access

Status
Not open for further replies.

hianjali

Programmer
Jan 5, 2006
29
US
Hello All,

I am a beginner in MS ACCESS and i have a very tight deadline assignment to work on. Someone please help.

I have to pull out the members who have their Effective Date more than six months from the given date.

This is the query i wrote, but i get an error

"This expression is typed incorrectly,or its too complex to be evaluated. for example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expressions to variables"

Someone please help me soon
 
This is the query i wrote
Which query ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Sorry about that...this is the query

SELECT DISTINCT elgdep.MEM_SOC_SEC_NUM, elgdep.MEM_DEP_CODE, elgemp.ENR_GRP_NUMBER, elgdep.MEM_EFFEC_DATE, elgdep.MEM_BIRTH_DATE, elgadr.erstat, elgadr.erzpcd
FROM elgadr, elgdep, elgemp
WHERE DateDiff('m', elgdep.MEM_EFFEC_DATE, Format([Today's Date],"yyyymmdd") > 6 )
GROUP BY elgdep.MEM_SOC_SEC_NUM, elgdep.MEM_DEP_CODE, elgemp.ENR_GRP_NUMBER, elgdep.MEM_EFFEC_DATE, elgdep.MEM_BIRTH_DATE, elgadr.erstat, elgadr.erzpcd
ORDER BY elgemp.ENR_GRP_NUMBER;
 
Try
Code:
WHERE Abs(DateDiff('m', elgdep.MEM_EFFEC_DATE, Date())) > 6
 
Get rid of the GROUP BY clause as you don't use any aggregate function.
I wonder you have no JOIN clause: are you sure you want a cartesian product of the 3 tables ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I did. Now it doesnt ask me to input today's date as well as i get an error "Data type mismatch in criteria expression"

SELECT DISTINCT elgdep.MEM_SOC_SEC_NUM, elgdep.MEM_DEP_CODE, elgemp.ENR_GRP_NUMBER, elgdep.MEM_EFFEC_DATE, elgdep.MEM_BIRTH_DATE, elgadr.erstat, elgadr.erzpcd
FROM elgadr, elgdep, elgemp
WHERE Abs(DateDiff('m', elgdep.MEM_EFFEC_DATE, Date())) > 6
GROUP BY elgdep.MEM_SOC_SEC_NUM, elgdep.MEM_DEP_CODE, elgemp.ENR_GRP_NUMBER, elgdep.MEM_EFFEC_DATE, elgdep.MEM_BIRTH_DATE, elgadr.erstat, elgadr.erzpcd
ORDER BY elgemp.ENR_GRP_NUMBER;
 
I now tried removing Group by and also used join...but still i get the same error

SELECT elgdep.MEM_SOC_SEC_NUM, elgdep.MEM_DEP_CODE, elgemp.ENR_GRP_NUMBER, elgdep.MEM_EFFEC_DATE, elgdep.MEM_BIRTH_DATE, elgadr.erstat, elgadr.erzpcd
FROM elgadr, elgdep INNER JOIN elgemp ON elgdep.MEM_SOC_SEC_NUM = elgemp.ENR_SOC_SEC_NUM
WHERE (((DateDiff('m',[elgdep].[MEM_EFFEC_DATE],Format([Today's Date],"yyyymmdd")>6))<>False))
ORDER BY elgemp.ENR_GRP_NUMBER;

"This expression is typed incorrectly,or its too complex to be evaluated. for example, a numeric expression may contain too many complicated elements. Try simplifying the expression by assigning parts of the expressions to variables"
 
PARAMETERS [Today's Date] DateTime;
SELECT elgdep.MEM_SOC_SEC_NUM, elgdep.MEM_DEP_CODE, elgemp.ENR_GRP_NUMBER, elgdep.MEM_EFFEC_DATE, elgdep.MEM_BIRTH_DATE, elgadr.erstat, elgadr.erzpcd
FROM (elgdep
INNER JOIN elgadr ON elgdep.??? = elgadr.???)
INNER JOIN elgemp ON elgdep.MEM_SOC_SEC_NUM = elgemp.ENR_SOC_SEC_NUM
WHERE elgdep.MEM_EFFEC_DATE < DateAdd('m',-6,[Today's Date])
ORDER BY elgemp.ENR_GRP_NUMBER;

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
Thanks PHV...I tried and i get "ODBC --call failed"

PARAMETERS [Today's Date] DateTime;
SELECT elgdep.MEM_SOC_SEC_NUM, elgdep.MEM_DEP_CODE, elgemp.ENR_GRP_NUMBER, elgdep.MEM_EFFEC_DATE, elgdep.MEM_BIRTH_DATE, elgadr.erstat, elgadr.erzpcd
FROM (elgdep
INNER JOIN elgadr ON elgdep.MEM_DEP_CODE = elgadr.erdpcd)
INNER JOIN elgemp ON elgdep.MEM_SOC_SEC_NUM = elgemp.ENR_SOC_SEC_NUM
WHERE elgdep.MEM_EFFEC_DATE < DateAdd('m',-6,[Today's Date])
ORDER BY elgemp.ENR_GRP_NUMBER;
 
What is the ODBC error ?
BTW, how is ODBC concerned ?

Hope This Helps, PH.
Want to get great answers to your Tek-Tips questions? Have a look at FAQ219-2884 or FAQ181-2886
 
I have clicked on File - Get External Data - Link Tables - and selected the datasource from ODBC datasources...and using those linked tables to build the query....Hope i made some sense
 
Status
Not open for further replies.

Part and Inventory Search

Sponsor

Back
Top