Re: Excel - Querytable - SQL
Assuming you have a Where clause, this condition will check for "between 07:00:00 and 20:00:00 "yesterday" ":
Code:
DateField Between (DateAdd('d', -1, Date) + #7:00:00#) And (DateAdd('d', -1, Date) + #20:00:00#)
...I'm not entirely sure if DateAdd is apt for this, but it hopefully will be (it is supported by Jet, which I presume is what is used).
Re: Excel - Querytable - SQL
Spot on Si!
Not in work till Thursday now, so I'll check it out then and will let you know!
Thanks!
Mitch
Re: Excel - Querytable - SQL
This is the string I've got when my code runs
can see you what the error is?
It's connects to an access database, my SQL isn't too hot!
Is there any where I could learn more advanced stuff like this?
Code:
SELECT * FROM PRDADMIN_EVENT WHERE (((PRDADMIN_EVENT.EVENTTYPEID)="RNDZ") AND ((PRDADMIN_EVENT.DATEEVENT) Between (DateAdd('d', -1, Date) + #7:00:00#) And (DateAdd('d', -1, Date) + #20:00:00#) AND ((PRDADMIN_EVENT.DESCRIPTION)="Reply Received - Outstanding = 0"));
Re: Excel - Querytable - SQL
I can't see what the error is, because only you have that information. ;)
All I know is that you've got an SQL statement that looks valid - I have no idea if it is giving you an actual error message, or if it is returning no data, or if it is returning the wrong data, or something else entirely.
Re: Excel - Querytable - SQL
My bad!
It says "SQL Syntax Error"
But I can't see what the problem could be! :(
new to this side of things!!
Re: Excel - Querytable - SQL
Where do you have your SQL? Is it saved in a variable within a VBA module, or is it just a query in MS Query, or... ?
Also, as for the syntax of your SQL, I think you have some extra parenthesis and some misplaced parenthesis.
I think your SQL should probably be:
Code:
SELECT *
FROM PRDADMIN_EVENT
WHERE (PRDADMIN_EVENT.EVENTTYPEID ="RNDZ") AND
(PRDADMIN_EVENT.DESCRIPTION ="Reply Received - Outstanding = 0") AND
(
PRDADMIN_EVENT.DATEEVENT BETWEEN (DateAdd('d', -1, Date) + #7:00:00#) AND
(DateAdd('d', -1, Date) + #20:00:00#)
);
Or, in one line:
Code:
SELECT * FROM PRDADMIN_EVENT WHERE (PRDADMIN_EVENT.EVENTTYPEID ="RNDZ") AND (PRDADMIN_EVENT.DESCRIPTION="Reply Received - Outstanding = 0") AND (PRDADMIN_EVENT.DATEEVENT BETWEEN (DateAdd('d', -1, Date) + #7:00:00#) AND (DateAdd('d', -1, Date) + #20:00:00#));