I am using PUT ShortQuery: https://api.opendental.com/api/v1/queries/ShortQuery
The following query does not return any results beyond 2020-09-26:
"SqlCommand": "SET @FromDate= '2020-04-29', @ToDate='2026-04-31'; select a.AptDateTime, p.FName, p.WirelessPhone FROM appointment a INNER JOIN patient p ON p.PatNum=a.PatNum WHERE a.AptDateTime BETWEEN @FromDate AND @ToDate"
I need it to return data in future i.e. pull patients with upcoming appointments (and not in the past)
So this does not return any results although there are appointments on 4/29/2026
"SqlCommand": "SET @FromDate= '2026-04-29', @ToDate='2026-04-31'; select a.AptDateTime, p.FName, p.WirelessPhone FROM appointment a INNER JOIN patient p ON p.PatNum=a.PatNum WHERE a.AptDateTime BETWEEN @FromDate AND @ToDate"
Can someone help with that please?
Thanks
ShortQuery help needed
-
Tom Zaccaria
- Posts: 366
- Joined: Mon Feb 25, 2008 3:09 am
Re: ShortQuery help needed
Use this in place of your from and to dates and just change the number of days you want to search past and present.
drtmz
(DATE(a.AptDateTime) BETWEEN curdate() AND curdate() +interval 10 day)
OR
(DATE(a.AptDateTime) BETWEEN curdate() AND curdate() -interval 10 day)
drtmz
(DATE(a.AptDateTime) BETWEEN curdate() AND curdate() +interval 10 day)
OR
(DATE(a.AptDateTime) BETWEEN curdate() AND curdate() -interval 10 day)
Re: ShortQuery help needed
I tried that. It still does not pull appointments and patients (although there is an appointment on 4/29)
-
Tom Zaccaria
- Posts: 366
- Joined: Mon Feb 25, 2008 3:09 am
Re: ShortQuery help needed
Take 2:
select a.AptDateTime, p.FName, p.WirelessPhone
FROM appointment a
INNER JOIN patient p ON p.PatNum=a.PatNum WHERE
(DATE(a.AptDateTime)
BETWEEN Curdate()+Interval 2 Day AND Curdate()+Interval 2 Day) AND a.AptStatus IN (1,2,4)
You will have to manipulate the interval days.
drtmz
select a.AptDateTime, p.FName, p.WirelessPhone
FROM appointment a
INNER JOIN patient p ON p.PatNum=a.PatNum WHERE
(DATE(a.AptDateTime)
BETWEEN Curdate()+Interval 2 Day AND Curdate()+Interval 2 Day) AND a.AptStatus IN (1,2,4)
You will have to manipulate the interval days.
drtmz
Re: ShortQuery help needed
Hello osjaved,osjaved wrote: Sat Apr 25, 2026 6:25 pm I am using PUT ShortQuery: https://api.opendental.com/api/v1/queries/ShortQuery
The following query does not return any results beyond 2020-09-26:
"SqlCommand": "SET @FromDate= '2020-04-29', @ToDate='2026-04-31'; select a.AptDateTime, p.FName, p.WirelessPhone FROM appointment a INNER JOIN patient p ON p.PatNum=a.PatNum WHERE a.AptDateTime BETWEEN @FromDate AND @ToDate"
I need it to return data in future i.e. pull patients with upcoming appointments (and not in the past)
So this does not return any results although there are appointments on 4/29/2026
"SqlCommand": "SET @FromDate= '2026-04-29', @ToDate='2026-04-31'; select a.AptDateTime, p.FName, p.WirelessPhone FROM appointment a INNER JOIN patient p ON p.PatNum=a.PatNum WHERE a.AptDateTime BETWEEN @FromDate AND @ToDate"
Can someone help with that please?
Thanks
Your query is likely invalid because April 31st isn't a real day.
You could try something like this:
Code: Select all
SELECT
a.AptDateTime,
p.FName,
p.WirelessPhone
FROM appointment a
INNER JOIN patient p
ON p.PatNum = a.PatNum
WHERE a.AptDateTime >= '2026-04-29 00:00:00'
AND a.AptDateTime < '2026-04-30 00:00:00'
ORDER BY a.AptDateTime;Re: ShortQuery help needed
Tried this one and still getting the same result
Re: ShortQuery help needed
Tried this one but still can't get results
Tom Zaccaria wrote: Mon Apr 27, 2026 6:35 am Take 2:
select a.AptDateTime, p.FName, p.WirelessPhone
FROM appointment a
INNER JOIN patient p ON p.PatNum=a.PatNum WHERE
(DATE(a.AptDateTime)
BETWEEN Curdate()+Interval 2 Day AND Curdate()+Interval 2 Day) AND a.AptStatus IN (1,2,4)
You will have to manipulate the interval days.
drtmz
Re: ShortQuery help needed
Hello osjaved,
Have you double checked that the authorization header is the same on both requests? It looks like the /appointments GET request has 8 headers, while the /queries/ShortQuery PUT request has 10 headers. After confirming that, can you test the result from the following command?
Code: Select all
SELECT AptDateTime from appointment WHERE AptNum=279;Re: ShortQuery help needed
Yes it was the incorrect header that was causing it. It works now. Thank you!