?
Solved

Sql Date Query

Posted on 2011-04-20
2
Medium Priority
?
270 Views
Last Modified: 2012-05-11
Hi All i have the following query which returns number of quotes for the current month of the current year.

What would i need to change in order to only get the number of quotes for the current day

Herre is the code

SELECT     TOP (100) PERCENT dbo.ihead.ih_account, dbo.ihead.ih_name, dbo.ihead.ih_quodate, dbo.ihead.ih_invdate, dbo.ihead.ih_quotat, dbo.ihead.ih_invoice,
                      dbo.ihead.ih_exvat, dbo.ihead.ih_vat, dbo.ihead.ih_fcurr, dbo.ihead.ih_region, dbo.ihead.ih_terrtry, dbo.ihead.ih_raised, dbo.slook.lk_desc,
                      dbo.V_Customer_Ref.comp_name, dbo.itran.it_anal, dbo.itran.it_status, dbo.itran.it_recno
FROM         dbo.ihead INNER JOIN
                      dbo.slook ON dbo.ihead.ih_terrtry = dbo.slook.lk_code LEFT OUTER JOIN
                      dbo.itran ON dbo.ihead.ih_doc = dbo.itran.it_doc LEFT OUTER JOIN
                      dbo.V_Customer_Ref ON dbo.ihead.ih_account = dbo.V_Customer_Ref.Customer_Ref
WHERE     (dbo.V_Customer_Ref.Customer_Ref IS NOT NULL) AND (dbo.ihead.ih_quotat > ' ') AND (dbo.itran.it_recno = '1') AND (dbo.itran.it_status = 'A') AND
                      (dbo.itran.it_anal > ' ') AND (DATEPART(yyyy, dbo.ihead.ih_quodate) = DATEPART(yyyy, GETDATE())) AND (DATEPART(m, dbo.ihead.ih_quodate) = DATEPART(m,
                      GETDATE()))
ORDER BY dbo.itran.it_anal

Thanks

John
0
Comment
Question by:pepps11976
  • 2
2 Comments
 
LVL 33

Accepted Solution

by:
knightEknight earned 2000 total points
ID: 35433034
AND (dbo.itran.it_anal > ' ')
AND (DATEPART(yyyy, dbo.ihead.ih_quodate) = DATEPART(yyyy, GETDATE()))
AND (DATEPART(m, dbo.ihead.ih_quodate) = DATEPART(m,GETDATE()))
AND (DATEPART(d, dbo.ihead.ih_quodate) = DATEPART(d,GETDATE()))

0
 
LVL 33

Expert Comment

by:knightEknight
ID: 35433077
or shorter:

AND (dbo.itran.it_anal > ' ')  
AND  convert(int,dbo.ihead.ih_quodate) = convert(int,getdate())
0

Featured Post

Granular recovery for Microsoft Exchange

With Veeam Explorer for Microsoft Exchange you can choose the Exchange Servers and restore points you’re interested in, and Veeam Explorer will present the contents of those mailbox stores for browsing, searching and exporting.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

SQL Server engine let you use a Windows account or a SQL Server account to connect to a SQL Server instance. This can be configured immediatly during the SQL Server installation or after in the Server Authentication section in the Server properties …
This shares a stored procedure to retrieve permissions for a given user on the current database or across all databases on a server.
Integration Management Part 2
Screencast - Getting to Know the Pipeline

864 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question