Hello,
I've created a query in Crystal and need to convert it to SQL to be run in a VB6 application. The query is as follows:
if {Calls.Date} = {Calls.DateReceived} and {Calls.Date} = Calls.DateTaken} and {Calls.TimeTaken}<>{Calls.Time} and
datediff("n",{Calls.Time},{Calls.DateReceived})>=.5 and
datediff("n",{Calls.Time},{Calls.TimeTaken}) <= 30
This Crystal query gives me the number of calls taken within the first half hour. Now in SQL i'm not sure how to get the datediff part of the query to work. This is what I have so far:
SELECT Calls.Date, Calls.DateReceived, Calls.DateTaken, Calls.Time, Calls.TimeTaken
FROM Calls
WHERE (((Calls.Date)=[DateReceived]) AND ((Calls.DateReceived)=Date()) AND ((Calls.DateTaken)=[Date]) AND ((Calls.Time)<>[TimeTaken]) AND ((Calls.TimeTaken)=[Calls]![Time] And (Calls.TimeTaken)=[Calls]![TimeTaken]));
As you can see there is no time comparison to get calls within the first 30 mins the call was taken.
Any help getting datediff("n",{Calls.Time},{Calls.DateReceived})>=.5 and
datediff("n",{Calls.Time},{Calls.TimeTaken}) <= 30 converted to SQL would be great.
Thanks,
Wyatt
I've created a query in Crystal and need to convert it to SQL to be run in a VB6 application. The query is as follows:
if {Calls.Date} = {Calls.DateReceived} and {Calls.Date} = Calls.DateTaken} and {Calls.TimeTaken}<>{Calls.Time} and
datediff("n",{Calls.Time},{Calls.DateReceived})>=.5 and
datediff("n",{Calls.Time},{Calls.TimeTaken}) <= 30
This Crystal query gives me the number of calls taken within the first half hour. Now in SQL i'm not sure how to get the datediff part of the query to work. This is what I have so far:
SELECT Calls.Date, Calls.DateReceived, Calls.DateTaken, Calls.Time, Calls.TimeTaken
FROM Calls
WHERE (((Calls.Date)=[DateReceived]) AND ((Calls.DateReceived)=Date()) AND ((Calls.DateTaken)=[Date]) AND ((Calls.Time)<>[TimeTaken]) AND ((Calls.TimeTaken)=[Calls]![Time] And (Calls.TimeTaken)=[Calls]![TimeTaken]));
As you can see there is no time comparison to get calls within the first 30 mins the call was taken.
Any help getting datediff("n",{Calls.Time},{Calls.DateReceived})>=.5 and
datediff("n",{Calls.Time},{Calls.TimeTaken}) <= 30 converted to SQL would be great.
Thanks,
Wyatt