SQL Server Forums
Profile | Register | Active Topics | Members | Search | Forum FAQ
 
Register Now and get your question answered!
Username:
Password:
Save Password
Forgot your Password?

 All Forums
 General SQL Server Forums
 New to SQL Server Programming
 MODIFY HELP
 New Topic  Reply to Topic
 Printer Friendly
Author Previous Topic Topic Next Topic  

anajjar
Starting Member

Canada
4 Posts

Posted - 12/05/2013 :  20:50:07  Show Profile  Reply with Quote
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

Malaysia
961 Posts

Posted - 12/05/2013 :  22:05:04  Show Profile  Reply with Quote

SELECT InvoiceDueDate, InvoiceNumber 
From Invoices 
WHERE InvoiceDueDate < DATEADD(m, DATEDIFF(m, 0, GETDATE()) + 1, 0) - 1
AND 
InvoiceNumber <> 0 balancedue > 0
Go to Top of Page

visakh16
Very Important crosS Applying yaK Herder

India
52317 Posts

Posted - 12/06/2013 :  04:56:49  Show Profile  Reply with Quote
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
  Previous Topic Topic Next Topic  
 New Topic  Reply to Topic
 Printer Friendly
Jump To:
SQL Server Forums © 2000-2009 SQLTeam Publishing, LLC Go To Top Of Page
This page was generated in 0.09 seconds. Powered By: Snitz Forums 2000