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

Поделиться
HTML-код
  • Опубликовано: 13 сен 2024
  • 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/que...
    98-364: Database Fundamentals (Microsoft SQL Server): rebrand.ly/dat...
    70-462 SQL Server Database Administration (DBA): rebrand.ly/sql...
    Microsoft SQL Server Reporting Services (SSRS): rebrand.ly/sql...
    SQL Server Integration Services (SSIS): rebrand.ly/sql...
    SQL Server Analysis Services (SSAS): rebrand.ly/sql...
    Microsoft Power Pivot (Excel) and SSAS (Tabular DAX model): rebrand.ly/mic...
    ----
    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/que...
    98-364: Database Fundamentals (Microsoft SQL Server): idodata.com/dat...
    SQL Server Essential in an Hour: idodata.com/sql...
    70-462 SQL Server Database Administration (DBA): idodata.com/sql...
    DP-300: Administering Relational Databases: idodata.com/dp-...
    Microsoft SQL Server Reporting Services (SSRS): idodata.com/mic...
    SQL Server Integration Services (SSIS): idodata.com/sql...
    SQL Server Analysis Services (SSAS): idodata.com/sql...
    Microsoft Power Pivot (Excel) and SSAS (Tabular DAX model): rebrand.ly/mic...
    1Z0-071 Oracle SQL Developer - certified associate: idodata.com/iz0...
    SQL for Microsoft Access: idodata.com/sql...
    DP-900: Microsoft Azure Data Fundamentals: idodata.com/dp-...

Комментарии • 1

  • @etienne6641
    @etienne6641 11 месяцев назад +1

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