Welcome to Excel Jet Consult blog post. In this tutorial, we want to learn how to use the WHERE clause to filter between two dates. Let’s get started.
In the caption below, we have the 2017 Data table fetched from our Transaction Records database
We want to retrieve Product, Account Manager, Order Priority, Total Revenue from the Sales Data between 2017-04-01 and 2017-04-15
In the query window, execute the query:
select Product, [Account Manager], [Order Priority], format([Total Revenue],’c’, ‘ng-ng’) as [Total Rev] from [2017 Data]
where [Order Date] between ‘2017-04-01’ and ‘2017-04-15’
The above query simply implies that we selected the Product, Account Manager, Order Priority and formatted Total Revenue columns. Furthermore, we provided [Total Rev] as the ALIAS from the 2017 Data. Then, we used the WHERE clause and between operator based on the dates value inside single quotes respectively
To run the query, execute F5 or the play button
From the caption above, we can see that the Total Rev for the first line of retrieved data is ₦1,434,453.20.
Conclusion
Writing advanced filter query is slightly easy once we know how to deploy the WHERE clause