Compiler-definitions for Delphi 10.3 Rio? - delphi-10.3-rio

Can anyone translate these compiler-definitions for Delphi 10.3 Rio? Thank you in advance.
{$IFDEF VER320} //Embarcadero Delphi 10.2 Tokyo (25 - Godzilla) - 2017
{$DEFINE D4PLUS}
{$DEFINE D5PLUS}
{$DEFINE D6PLUS}
{$DEFINE D7PLUS}
{$DEFINE BDS3PLUS}{$DEFINE D2005PLUS}
{$DEFINE BDS4PLUS}{$DEFINE D2006PLUS}
{$DEFINE RAD5PLUS}{$DEFINE D2007PLUS}
{$DEFINE RAD6PLUS}{$DEFINE D2009PLUS}
{$DEFINE RAD7PLUS}{$DEFINE D2010PLUS}
{$DEFINE RAD8PLUS}{$DEFINE DXEPLUS}
{$DEFINE RAD9PLUS}{$DEFINE DXE2PLUS}
{$DEFINE RAD10PLUS}{$DEFINE DXE3PLUS}
{$DEFINE RAD11PLUS}{$DEFINE DXE4PLUS}
{$DEFINE RAD12PLUS}{$DEFINE DXE5PLUS}
{$DEFINE RAD14PLUS}{$DEFINE DXE6PLUS}
{$DEFINE RAD15PLUS}{$DEFINE DXE7PLUS}
{$DEFINE RAD16PLUS}{$DEFINE DXE8PLUS}
{$DEFINE RAD17PLUS}{$DEFINE DSEATTLEPLUS}{$DEFINE DXSPLUS}
{$DEFINE RAD18PLUS}{$DEFINE DBERLINPLUS}{$DEFINE DXBPLUS}
{$DEFINE RAD19PLUS}{$DEFINE DTOKYOPLUS}{$DEFINE DXTPLUS}
{$DEFINE THEMESUPPORT}
{$DEFINE NATIVEINT}
{$ENDIF}

{$IFDEF VER330} //Embarcadero Delphi 10.3 Rio (26 - ?) - 2018
{$DEFINE D4PLUS}
{$DEFINE D5PLUS}
{$DEFINE D6PLUS}
{$DEFINE D7PLUS}
{$DEFINE BDS3PLUS}{$DEFINE D2005PLUS}
{$DEFINE BDS4PLUS}{$DEFINE D2006PLUS}
{$DEFINE RAD5PLUS}{$DEFINE D2007PLUS}
{$DEFINE RAD6PLUS}{$DEFINE D2009PLUS}
{$DEFINE RAD7PLUS}{$DEFINE D2010PLUS}
{$DEFINE RAD8PLUS}{$DEFINE DXEPLUS}
{$DEFINE RAD9PLUS}{$DEFINE DXE2PLUS}
{$DEFINE RAD10PLUS}{$DEFINE DXE3PLUS}
{$DEFINE RAD11PLUS}{$DEFINE DXE4PLUS}
{$DEFINE RAD12PLUS}{$DEFINE DXE5PLUS}
{$DEFINE RAD14PLUS}{$DEFINE DXE6PLUS}
{$DEFINE RAD15PLUS}{$DEFINE DXE7PLUS}
{$DEFINE RAD16PLUS}{$DEFINE DXE8PLUS}
{$DEFINE RAD17PLUS}{$DEFINE DSEATTLEPLUS}{$DEFINE DXSPLUS}
{$DEFINE RAD18PLUS}{$DEFINE DBERLINPLUS}{$DEFINE DXBPLUS}
{$DEFINE RAD19PLUS}{$DEFINE DTOKYOPLUS}{$DEFINE DXTPLUS}
{$DEFINE RAD20PLUS}{$DEFINE DRIOPLUS}{$DEFINE DXRPLUS}
{$DEFINE THEMESUPPORT}
{$DEFINE NATIVEINT}
{$ENDIF}

Related

Exapansion of rows based on Calendar

My fact table is following
declare #fact as TABLE (WO varchar(3), startYear int, startFiscalPeriod int, endFiscalPeriod int)
INSERT INTO #fact
Select WO, startYear,startFiscalPeriod, endFiscalPeriod
from
(
VALUES
('WO1', 2020, 202011, 202106),
('WO2', 2020, 202009, 202106),
('WO3', 2021, 202102, 202106)
) t (WO, startYear,startFiscalPeriod, endFiscalPeriod)
select * from #fact
WO
startYear
startFiscalPeriod
endFiscalPeriod
WO1
2020
202011
202106
WO2
2020
202009
202106
WO3
2021
202102
202106
I want to expand the rows based on the interval between startFiscalPeriod and endFiscalPeriod, like following
;with cte as
(select WO, startYear,startFiscalPeriod, endFiscalPeriod from #fact
UNION ALL
select WO, startYear,startFiscalPeriod+1,endFiscalPeriod from CTE
where startFiscalPeriod<[endFiscalPeriod])
However, I want the expansion to happen based on a calendarTable.
declare #Calendar as TABLE (fiscalYear int, periodNumber int, fiscalPeriod int)
INSERT INTO #Calendar
Select fiscalYear, periodNumber,fiscalPeriod
from
(
VALUES
(2020, 1, 202001),
(2020, 2, 202002),
(2020, 3, 202003),
(2020, 4, 202004),
(2020, 5, 202005),
(2020, 6, 202006),
(2020, 7, 202007),
(2020, 8, 202008),
(2020, 9, 202009),
(2020, 10, 202010),
(2020, 11, 202011),
(2020, 12, 202012),
(2021, 1, 202101),
(2021, 2, 202102),
(2021, 3, 202103),
(2021, 4, 202104),
(2021, 5, 202105),
(2021, 6, 202106)
) t (fiscalYear, periodNumber,fiscalPeriod)
My desired output is following which I can't generate by simply expanding the rows on simple do while logic. Is there any way to condition the do while logic based on the calendar?
WO
startYear
startFiscalPeriod
endFiscalPeriod
WO1
2020
202011
202106
WO1
2020
202012
202106
WO1
2020
202101
202106
WO1
2020
202102
202106
WO1
2020
202103
202106
WO1
2020
202104
202106
WO1
2020
202105
202106
WO1
2020
202106
202106
WO2
2020
202009
202106
WO2
2020
202010
202106
WO2
2020
202011
202106
WO2
2020
202012
202106
WO2
2020
202101
202106
WO2
2020
202102
202106
WO2
2020
202103
202106
WO2
2020
202104
202106
WO2
2020
202105
202106
WO2
2020
202106
202106
WO3
2021
202102
202106
WO3
2021
202103
202106
WO3
2021
202104
202106
WO3
2021
202105
202106
WO3
2021
202106
202106
Thank you in advance
Why not join the two tables with a between condition, like Calendar.fiscalPeriod between fact.startFiscalPeriod and fact.endFiscalPeriod?
select
f.WO
, f.startYear
, c.fiscalPeriod startFiscalPeriod
, f.endFiscalPeriod
from
#fact f
inner join #Calendar c on c.fiscalPeriod between f.startFiscalPeriod and f.endFiscalPeriod
order by
f.WO
, c.fiscalPeriod

Aggregate at 10 minutes for last 24 hours in db

The following query splits given time range data into 5 minutes but it does this thing from start of timerange provided
With MNE
AS
(
SELECT *,DATEDIFF(dd,0,t.datetime) AS dayoffset,
DATEDIFF(ss,MIN(t.datetime) OVER (PARTITION BY DATEDIFF(dd,0,t.datetime)),t.datetime)/60 AS MinOffset
FROM cw.datas t
WHERE t.DATETIME <= GETDATE()
AND t.DATETIME > DATEADD(SECOND, -DATEDIFF(SECOND, CAST(CAST(GETDATE() AS DATE) AS DATETIME),
GETDATE()) % (60 * 5), DATEADD(DAY, - 1,GETDATE()))
)
SELECT MIN(z.datetime) AS StartDatetime,
MAX(z.datetime) AS ENdDatetime,
sum(z.value) AS TotalSum
FROM MNE z
GROUP BY dayoffset,(MinOffset-1)/10
order by StartDatetime
With current time as 2020-09-14 12:28:43.793, The output comes in following way :
StartDatetime,ENdDatetime,TotalSum
2020-09-13 12:25:03.000, 2020-09-13 12:31:00.000, 63763.51
2020-09-13 12:31:03.000, 2020-09-13 12:36:00.000, 48348.34
2020-09-13 12:36:03.000, 2020-09-13 12:41:00.000, 54387.69
--
--
2020-09-14 12:16:00.000, 2020-09-14 12:20:57.000, 54353.72
2020-09-14 12:21:00.000, 2020-09-14 12:25:57.000, 53780.48
2020-09-14 12:26:00.000, 2020-09-14 12:28:42.000, 25328.56
I want aggregation of split from current timestamp i.e. 2020-09-14 12:28:43.793 back to last 24 hours.
Expected result :
StartDatetime,ENdDatetime,TotalSum
--
--
2020-09-14 11:58:43.000, 2020-09-14 12:08:43.000, 354654
2020-09-14 12:08:43.000, 2020-09-14 12:18:43.000, 354353
2020-09-14 12:18:43.000, 2020-09-14 12:28:43.000, 354665
Help appreciated.
Sample Data :
datas
datetime, abc, def, ghi, value
2020-09-11 12:22:36.000, AYSH, mains, SAE, 363.12
2020-09-11 12:22:39.000, AYSH, mains, SAE, 358.2
2020-09-11 12:22:42.000, AYSH, mains, SAE, 353.66
2020-09-11 12:22:45.000, AYSH, mains, SAE, 349.14
2020-09-11 12:22:48.000, AYSH, mains, SAE, 344.84
2020-09-11 12:22:51.000, AYSH, mains, SAE, 340.63
2020-09-11 12:22:54.000, AYSH, mains, SAE, 336.45
You did not provide table definitions for cw.datas so I cannot apply my solution to your query.
This recursive CTE generates the 144 intervals with duration of 10 minutes starting from now and going back 24 hours.
with stamps as
(
select getdate() as Stamp, 0 as Interval
union all
select dateadd(MI, -10, s.Stamp), s.Interval+1
from stamps s
where s.Interval < 144 -- 24 hours * 6 10-minute intervals = 144 10-minute intervals
)
select s.Stamp as FromDateTime,
dateadd(MI, 10, s.Stamp) as ToDateTime,
s.Interval
from stamps s
order by s.Stamp
option(maxrecursion 144);
Output looks like:
FromDateTime ToDateTime Interval
--------------------------- --------------------------- ---------
2020-09-13 14:00:54.740 2020-09-13 14:10:54.740 144
2020-09-13 14:10:54.740 2020-09-13 14:20:54.740 143
2020-09-13 14:20:54.740 2020-09-13 14:30:54.740 142
2020-09-13 14:30:54.740 2020-09-13 14:40:54.740 141
2020-09-13 14:40:54.740 2020-09-13 14:50:54.740 140
...
2020-09-14 13:10:54.740 2020-09-14 13:20:54.740 5
2020-09-14 13:20:54.740 2020-09-14 13:30:54.740 4
2020-09-14 13:30:54.740 2020-09-14 13:40:54.740 3
2020-09-14 13:40:54.740 2020-09-14 13:50:54.740 2
2020-09-14 13:50:54.740 2020-09-14 14:00:54.740 1
2020-09-14 14:00:54.740 2020-09-14 14:10:54.740 0
Fiddle 1
Combination with the given sample data.
Sample data
create table data
(
stamp datetime,
abc nvarchar(4),
def nvarchar(5),
ghi nvarchar(3),
value decimal(10,2)
);
insert into data (stamp, abc, def, ghi, value) values
('2020-09-11 12:22:36.000', 'AYSH', 'mains', 'SAE', 363.12),
('2020-09-11 12:22:39.000', 'AYSH', 'mains', 'SAE', 358.2 ),
('2020-09-11 12:22:42.000', 'AYSH', 'mains', 'SAE', 353.66),
('2020-09-11 12:22:45.000', 'AYSH', 'mains', 'SAE', 349.14),
('2020-09-11 12:22:48.000', 'AYSH', 'mains', 'SAE', 344.84),
('2020-09-11 12:22:51.000', 'AYSH', 'mains', 'SAE', 340.63),
('2020-09-11 12:22:54.000', 'AYSH', 'mains', 'SAE', 336.45);
Solution
Defines a reference datetime because getdate() would produce few results with sample data for 2020-09-11.
declare #refStamp datetime = '2020-09-12 00:00:00.000'; -- replacement for getdate()
with stamps as
(
select #refStamp as FromDateTime,
dateadd(MI,10,#refStamp) as ToDateTime,
0 as Interval
union all
select dateadd(MI, -10, s.FromDateTime),
s.FromDateTime,
s.Interval+1
from stamps s
where s.Interval < 144 -- 24 hours * 6 10-minute intervals = 144 10-minute intervals
)
select s.FromDateTime,
s.ToDateTime,
d.abc,
sum(d.value) as SumValues
from stamps s
left join data d
on d.stamp >= s.FromDateTime -- greater than or equal to FromDateTime
and d.stamp < s.ToDateTime -- smaller than ToDateTime
where s.FromDateTime >= '2020-09-11 12:00:00.000' -- limit output results (part 1)
and s.FromDateTime <= '2020-09-11 13:00:00.000' -- limit output results (part 2)
group by s.FromDateTime, s.ToDateTime, d.abc
order by s.FromDateTime
option(maxrecursion 144);
Result
FromDateTime ToDateTime abc SumValues
------------------------ ------------------------ ----- ----------
2020-09-11 12:00:00.000 2020-09-11 12:10:00.000 NULL NULL
2020-09-11 12:10:00.000 2020-09-11 12:20:00.000 NULL NULL
2020-09-11 12:20:00.000 2020-09-11 12:30:00.000 AYSH 2446.04
2020-09-11 12:30:00.000 2020-09-11 12:40:00.000 NULL NULL
2020-09-11 12:40:00.000 2020-09-11 12:50:00.000 NULL NULL
2020-09-11 12:50:00.000 2020-09-11 13:00:00.000 NULL NULL
2020-09-11 13:00:00.000 2020-09-11 13:10:00.000 NULL NULL
Fiddle 2
If the data is dense then it's really not necessary to use the recursive query. Just compute the number of seconds elapsed since startTime. And this form lets you easily adjust the range start and size of the interval.
with timeRelatedFields as (
select
dateadd(hour, -24,
dateadd(millisecond, -datepart(millisecond, getdate()),
getdate())) as startTime,
600 as intervalSeconds
), tableTimeRelatedFields as (
select *,
d.value as consideredValue,
datediff(second, st.startTime, d."datetime") / intervalSeconds as interval
from cw.datas as d cross apply timeRelatedFields as st
where d."datetime" >= startTime and d."datetime" < getdate()
)
select
dateadd(second, intervalSeconds * interval, startTime) as StartDateTime,
dateadd(second, intervalSeconds * (interval + 1), startTime) as EndDateTime,
sum(consideredValue) as TotalSum
from tableTimeRelatedFields
group by interval;

A fractional DATEDIFF for SQLServer?

Found out something recently (and sure, my fault for not reading the docs) that reasonably horrified me about SQLServer's DATEDIFF function; it counts the number of interval boundaries between the two specified dates.
This means I can ask it for the number of days between 01 Jan 23:57 and 01 Jan 23:59 and it will return 0, but if I ask for the days between 01 Jan 23:59 and 02 Jan 00:01 it will tell me there is 1 day between them. The timespan is the same: 2 minutes, but suddenly one is a difference of 0 days and one is a difference of 1 day
Coming from an Oracle and .Net background I can see I've made a gross error in assuming that DATEDIFF in TSQL worked equivalently (i.e. prepare a timespan and then round it to the specified interval), but what is the alternative?
If I want to find out exactly, with decimal places, how many years there are between 2 dates, how do I do it in SQLServer? I don't want a result from 01 Jan to 31 Dec returning 0 years, but 31 dec 2000 to 01 jan 2002 returning 2 years, because these are gross errors and miles away from the 0.997 and 1.005 (not exact calcs) they should more likely be..
The answer clearly isn't to DATEDIFF the days and divide by 365.0, not only because datediff is routinely "wrong" even for DAYS (as per my 2 minute example) but also because there aren't always 365 days in a year. Same for months -> they aren't always a specified number of intervals long, so it doesn't make sense to take days and divide by 31 (or 30, 29, or 28).. For the same reasons I cannot do simple (endDateTime - startDateTime)/x math
If you want accuracy, you can go for minutes when doing the datediff and multiply the result accordingly. You can tweak the #dateFrom and #dateTo to test the outputs with the below code:
DECLARE #dateFrom DATETIME, #dateTo DATETIME
SET #dateFrom = '2017-07-01 23:59'
SET #dateTo = '2017-07-02 00:01'
SELECT DATEDIFF(MINUTE, #dateFrom, #dateTo) minsDiff
SELECT DATEDIFF(MINUTE, #dateFrom, #dateTo) / 60.0 hoursDiff
SELECT DATEDIFF(MINUTE, #dateFrom, #dateTo) / 60.0 / 24.0 daysDiff
SELECT DATEDIFF(MINUTE, #dateFrom, #dateTo) / 60.0 / 24.0 / 365.25 yearsDiff
SELECT DATEDIFF(MINUTE, #dateFrom, #dateTo) / 60.0 / 24.0 / 365.25 * 12 monthsDiff
It all depends on what you want to report and what your business logic is. You can do additional queries like so:
-- to track a change in days - take off the time portion:
SELECT DATEDIFF(DAY, CAST(#dateFrom AS DATE), CAST(#dateTo AS DATE)) daysDiff
-- to track a change in years - you use the year funtion:
SELECT YEAR(#dateTo) - YEAR(#dateFrom) yearsDiff
UPDATE: this code does not include DST.
You can also build your own code, which will be calculating difference between dates and put it into function.
DECLARE #dateFrom DATETIME, #dateTo DATETIME
SET #dateFrom = '2000-12-31 23:59'
SET #dateTo = '2002-01-02 00:01'
SELECT DATEDIFF(YEAR, DATEADD(year,DATEDIFF(year,0,DATEADD(year,1,#dateFrom)),0), DATEADD(year,DATEDIFF(year,0,#dateTo),0))
+ CASE WHEN YEAR(#dateFrom) < YEAR(#dateTo) THEN (DATEDIFF(MINUTE, #dateFrom, CAST(YEAR(#dateFrom) AS CHAR(4))+'-12-31 23:59') + 1) / (1.0*DATEDIFF(minute, CAST(YEAR(#dateFrom) AS CHAR(4))+'-01-01 00:00', CAST(YEAR(#dateFrom) AS CHAR(4))+'-12-31 23:59') + 1)
+ (DATEDIFF(MINUTE, CAST(YEAR(#dateTo) AS CHAR(4))+'-01-01 00:00',#dateTo ) + 1) / (1.0*DATEDIFF(minute, CAST(YEAR(#dateTo) AS CHAR(4))+'-01-01 00:00', CAST(YEAR(#dateTo) AS CHAR(4))+'-12-31 23:59') + 1)
ELSE (DATEDIFF(MINUTE,#dateFrom, #dateTo) + 1) / (1.0*DATEDIFF(minute, CAST(YEAR(#dateTo) AS CHAR(4))+'-01-01 00:00', CAST(YEAR(#dateTo) AS CHAR(4))+'-12-31 23:59') + 1) END
--Result: 1.002745428591627
This code needs comments, so:
+1 is needed to obtain exact number of minutes between dates.
This is used for calculating how many minutes year has.
(1.0*DATEDIFF(minute, CAST(YEAR(#dateTo) AS CHAR(4))+'-01-01 00:00', CAST(YEAR(#dateTo) AS CHAR(4))+'-12-31 23:59') + 1)
This give us beginning of the year.
DATEADD(year,DATEDIFF(year,0,#dateTo),0)
This piece of code is calculating full years between #dateFrom and #dateTo.
DATEDIFF(YEAR, DATEADD(year,DATEDIFF(year,0,DATEADD(year,1,#dateFrom)),0), DATEADD(year,DATEDIFF(year,0,#dateTo),0))
This is calculating "partial" years. We are calculating how many minutes left to the end of year.
(DATEDIFF(MINUTE, #dateFrom, CAST(YEAR(#dateFrom) AS CHAR(4))+'-12-31 23:59') + 1) / (1.0*DATEDIFF(minute, CAST(YEAR(#dateFrom) AS CHAR(4))+'-01-01 00:00', CAST(YEAR(#dateFrom) AS CHAR(4))+'-12-31 23:59') + 1)
Similary to what we have above but for #dateTo.
(DATEDIFF(MINUTE, CAST(YEAR(#dateTo) AS CHAR(4))+'-01-01 00:00',#dateTo ) + 1) / (1.0*DATEDIFF(minute, CAST(YEAR(#dateTo) AS CHAR(4))+'-01-01 00:00', CAST(YEAR(#dateTo) AS CHAR(4))+'-12-31 23:59') + 1)
Here, we are calculating years when #dateFrom and #dateTo have the same year part.
(DATEDIFF(MINUTE,#dateFrom, #dateTo) + 1) / (1.0*DATEDIFF(minute, CAST(YEAR(#dateTo) AS CHAR(4))+'-01-01 00:00', CAST(YEAR(#dateTo) AS CHAR(4))+'-12-31 23:59') + 1)

Changing Date Format of Twitter Api DATA in SQL SERVER

i want to change date format of twitter api data it like this :
Fri Sep 11 08:31:48 +0000 2009
i want to convert it into format like this :
YYYY-DD-MM 00:00:00
How do i convert this in sql server 2012
Kinda late, but this is what worked for me
alter table Test
add [date2] as (
CONVERT(DATETIME, SUBSTRING(created_at,9,2)+'/'
+ CASE SUBSTRING(created_at,5,3)
WHEN 'Jan' then '01/'
WHEN 'Feb' then '02/'
WHEN 'Mar' then '03/'
WHEN 'Apr' then '04/'
WHEN 'May' then '05/'
WHEN 'Jun' then '06/'
WHEN 'Jul' then '07/'
WHEN 'Aug' then '08/'
WHEN 'Sep' then '09/'
WHEN 'Oct' then '10/'
WHEN 'Nov' then '11/'
WHEN 'Dec' then '12/'
else '' end
+RIGHT(created_at,4) + ' '
+ SUBSTRING(created_at,12,8), 105)
)
PERSISTED;

SQL query returns different results when run from Excel

A have a query that returns different results when run directly in SQL Server Management Studio and when run from Excel (using the SQLOLEDB provider). Both return a table with 12 rows (one per month) and two columns (date and a complex count), but some of the numeric values are incorrect in the Excel result set.
I'm happy to show you the full detail, but to start with can you suggest what type of things can cause such a difference?
Versions: SQL Server 10.50.4000, Excel 2013
Edit: the full details ...
select cast(ActualDate as date) as 'Start of rolling 12 months'
, count(distinct x.con_id) as 'Total Sponsors'
from DateTimeDimV4.dbo.datedim
join (select cm_id, con_id
, cm.start_date as activation_date
, isnull(stop_date, getdate()) as stop_date
from cm
join con_act ca on ca.con_act_db_id = cm.con_act_db_id and ca.con_act_id = cm.con_act_id
where
ca.code = 'corres'
) X on cast(activation_date as date) <= cast(ActualDate as date)
and cast(stop_date as date) > cast(ActualDate as date)
where
--ActualDate = eomonth(ActualDate) -- only works in SQL 2012, so instead we use ...
ActualDate = DATEADD(dd, -DAY(DATEADD(mm, 1, ActualDate)), DATEADD(mm, 1, ActualDate))
and ActualDate >= '31 Jul 2012' and ActualDate <= '30 June 2013'
group by cast(ActualDate as date)
order by cast(ActualDate as date)
In SSMS, this returns ...
Start of rolling 12 months Total Sponsors
2012-07-31 862
2012-08-31 872
2012-09-30 872
2012-10-31 880
2012-11-30 876
2012-12-31 878
2013-01-31 882
2013-02-28 888
2013-03-31 887
2013-04-30 887
2013-05-31 920
2013-06-30 933
But in Excel I get ...
Start of rolling 12 months Total Sponsors
2012-07-31 862
2012-08-31 872
2012-09-30 872
2012-10-31 880
2012-11-30 876
2012-12-31 878
2013-01-31 882
2013-02-28 887
2013-03-31 887
2013-04-30 887
2013-05-31 887
2013-06-30 887
Note that the first seven rows are identical but that Excel repeats the same incorrect value in the last five rows.
Also note that if I change the literal dates from '31 Jul 2012' and '30 June 2013' to '31 Jul 2011' and '30 June 2012' then the two environments produce results that are identical to each other.
Try changing:
and ActualDate >= '31 Jul 2012' and ActualDate <= '30 June 2013'
to:
and ActualDate >= '2012-07-31' and ActualDate <= '2013-06-30'
My logic: I think that MS Query is interpreting the literal date differently than SSMS. I can't prove it, though, since I can't find any documentation on MS Query. Scratch that. Let's just call it a hunch.
I usually stick with the ISO date formats for all my date literals.
Also, why did you abbreviate July but not June?
PICNIC indeed! Sorry for wasting your time.
The Excel version was executing the query against the correct server, but the wrong database. It was executing against a backup database whose name was only one character different from the live one.

Resources