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

Sdílet
Vložit
  • čas přidán 27. 09. 2023
  • 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: rebrand.ly/querying-microsoft...
    98-364: Database Fundamentals (Microsoft SQL Server): rebrand.ly/database-fundamentals
    70-462 SQL Server Database Administration (DBA): rebrand.ly/sql-server-dba
    Microsoft SQL Server Reporting Services (SSRS): rebrand.ly/sql-server-ssrs
    SQL Server Integration Services (SSIS): rebrand.ly/sql-server-ssis
    SQL Server Analysis Services (SSAS): rebrand.ly/sql-server-ssas-mdx
    Microsoft Power Pivot (Excel) and SSAS (Tabular DAX model): 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: idodata.com/querying-microsoft...
    98-364: Database Fundamentals (Microsoft SQL Server): idodata.com/database-fundament...
    SQL Server Essential in an Hour: idodata.com/sql-server-essenti...
    70-462 SQL Server Database Administration (DBA): idodata.com/sql-server-databas...
    DP-300: Administering Relational Databases: idodata.com/dp-300-administeri...
    Microsoft SQL Server Reporting Services (SSRS): idodata.com/microsoft-sql-serv...
    SQL Server Integration Services (SSIS): idodata.com/sql-server-integra...
    SQL Server Analysis Services (SSAS): idodata.com/sql-server-ssas-mu...
    Microsoft Power Pivot (Excel) and SSAS (Tabular DAX model): rebrand.ly/microsoft-powerpiv...
    1Z0-071 Oracle SQL Developer - certified associate: idodata.com/iz0-071-oracle-sql...
    SQL for Microsoft Access: idodata.com/sql-for-microsoft-...
    DP-900: Microsoft Azure Data Fundamentals: idodata.com/dp-900-microsoft-a...
  • Věda a technologie

Komentáře • 1

  • @etienne6641
    @etienne6641 Před 9 měsíci +1

    Very handy, this is a much shorter way. Thanks!