Retrieve all invoices in SQL Server with a date between now and a month from now

Опубликовано: 30 Сентябрь 2024
на канале: SQL Server 101
418
28

How can we write a T-SQL query which have an invoice date between now and a month later?
My SQL Server Udemy courses are:
70-461, 70-761 Querying Microsoft SQL Server with T-SQL: https://rebrand.ly/querying-microsoft...
98-364: Database Fundamentals (Microsoft SQL Server): https://rebrand.ly/database-fundamentals
70-462 SQL Server Database Administration (DBA): https://rebrand.ly/sql-server-dba
Microsoft SQL Server Reporting Services (SSRS): https://rebrand.ly/sql-server-ssrs
SQL Server Integration Services (SSIS): https://rebrand.ly/sql-server-ssis
SQL Server Analysis Services (SSAS): https://rebrand.ly/sql-server-ssas-mdx
Microsoft Power Pivot (Excel) and SSAS (Tabular DAX model): https://rebrand.ly/microsoft-powerpiv...
----
In this video, we'll show you how to retrieve all invoices in SQL Server with a date between now and a month from now.

If you need to retrieve invoices that were created between now and a month from now, then this video is for you! We'll show you how to retrieve all the invoices in SQL Server using the SELECT statement. This technique is useful if you need to review invoices or process payments. Thanks for watching!

The starting code is:
-- Today's date: 2023-09-27 15:00:00

DROP TABLE IF EXISTS Invoices;
CREATE TABLE Invoices
(InvoiceDate datetime,
InvoiceAmount int);
INSERT INTO Invoices
VALUES
('2023-08-27', 1), ('2023-09-08', 1), ('2023-09-15', 1),
('2023-09-27', 3), ('2023-09-29', 2), ('2023-10-06', 2),
('2023-10-13', 5), ('2023-10-20', 3), ('2023-10-27 01:00:00', 3),
('2023-11-03', 8), ('2023-11-10', 1), ('2023-11-17', 2),
('2023-11-24', 3), ('2023-12-01', 4), ('2023-12-08', 1);
SELECT InvoiceDate, InvoiceAmount
FROM Invoices
----
Links to my website are:
70-461, 70-761 Querying Microsoft SQL Server with T-SQL: http://idodata.com/querying-microsoft...
98-364: Database Fundamentals (Microsoft SQL Server): http://idodata.com/database-fundament...
SQL Server Essential in an Hour: http://idodata.com/sql-server-essenti...
70-462 SQL Server Database Administration (DBA): http://idodata.com/sql-server-databas...
DP-300: Administering Relational Databases: http://idodata.com/dp-300-administeri...
Microsoft SQL Server Reporting Services (SSRS): http://idodata.com/microsoft-sql-serv...
SQL Server Integration Services (SSIS): http://idodata.com/sql-server-integra...
SQL Server Analysis Services (SSAS): http://idodata.com/sql-server-ssas-mu...
Microsoft Power Pivot (Excel) and SSAS (Tabular DAX model): https://rebrand.ly/microsoft-powerpiv...
1Z0-071 Oracle SQL Developer – certified associate: http://idodata.com/iz0-071-oracle-sql...
SQL for Microsoft Access: http://idodata.com/sql-for-microsoft-...
DP-900: Microsoft Azure Data Fundamentals: http://idodata.com/dp-900-microsoft-a...