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.
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) - 1AND InvoiceNumber <> 0 balancedue > 0[/code] |
|
|
visakh16
Very Important crosS Applying yaK Herder
52326 Posts |
Posted - 2013-12-06 : 04:56:49
|
invoiceduedate that's less than 30 days from todayshould be below if you consider rolling 30 days rather than absolute monthSELECT InvoiceDueDate, InvoiceNumber From Invoices WHERE InvoiceDueDate < GETDATE()+ 31AND balancedue > 0 ------------------------------------------------------------------------------------------------------SQL Server MVPhttp://visakhm.blogspot.com/https://www.facebook.com/VmBlogs |
|
|
|
|
|