Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 MODIFY HELP

Author  Topic 

anajjar
Starting Member

4 Posts

Posted - 2013-12-05 : 20:50:07
Can some one please help me out:

A)write a select statement that returns invoicenumber and balancedue fro every invoice with a non-zero balance and an invoiceduedate that's less than 30 days from today...not sure what today is and also can you please check the script for me I am doing some thing wrong.

SELECT InvoiceDueDate, InvoiceNumber
From Invoices
WHERE DATEDIFF(dd, InvoiceDueDate, getdate()) < 30
AND
InvoiceNumber <> 0


modify the search explanation for invoiceduedate from the solution for part A. Rather than 30 days from today, return invoices due before the last day of current month.....not sure how to approach this.

thanks alot

waterduck
Aged Yak Warrior

982 Posts

Posted - 2013-12-05 : 22:05:04
[code]
SELECT InvoiceDueDate, InvoiceNumber
From Invoices
WHERE InvoiceDueDate < DATEADD(m, DATEDIFF(m, 0, GETDATE()) + 1, 0) - 1
AND
InvoiceNumber <> 0 balancedue > 0
[/code]
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

52326 Posts

Posted - 2013-12-06 : 04:56:49
invoiceduedate that's less than 30 days from today
should be below if you consider rolling 30 days rather than absolute month

SELECT InvoiceDueDate, InvoiceNumber
From Invoices
WHERE InvoiceDueDate < GETDATE()+ 31
AND balancedue > 0



------------------------------------------------------------------------------------------------------
SQL Server MVP
http://visakhm.blogspot.com/
https://www.facebook.com/VmBlogs
Go to Top of Page
   

- Advertisement -