'Difference Between SQL Server Management Studio date filter and Excel/PowerBI date filter

I have a SQL query which looks like this:

SELECT * 
FROM TABLE 
WHERE Date >='2019' 

which results in 214.096 rows.

If I copy the results (214.096 rows) into Excel or PowerBI and filter for Date >= 2022, I get 11.460 results for 2022 (in both Excel and Power BI).

However if use the following query:

SELECT * 
FROM TABLE 
WHERE DATE >= '2022' 

I get 13.157 rows.

For the other years I get the following results:

2019

  • Excel/Power BI: 70.091

  • SQL: 70.091

      SELECT * 
      FROM TABLE 
      WHERE DATE >= '2019' AND DATE < '2020'
    

2020

  • Excel/Power BI: 67.645

  • SQL : 69.401

      SELECT * 
      FROM TABLE 
      WHERE DATE >= '2020' AND DATE < '2021'
    

2021

  • Excel/Power BI: 64.902 SQL : 69.516

      SELECT * 
      FROM TABLE 
      WHERE DATE >= '2021' AND DATE < '2022'
    

2022

  • Excel/Power BI: 11.460

  • SQL : 13.157

      SELECT * 
      FROM TABLE 
      WHERE DATE >= '2022' AND < '2023'
    
  • That equals in Excel/PowerBI: 214.096

  • In SQL for the query with Date >= '2019': 214.096

  • If I sum the different queries for the years: 222.165

What am I doing wrong?



Sources

This article follows the attribution requirements of Stack Overflow and is licensed under CC BY-SA 3.0.

Source: Stack Overflow

Solution Source