Sql Date Query

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
pepps11976Asked:
Who is Participating?
 
knightEknightConnect With a Mentor Commented:
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
 
knightEknightCommented:
or shorter:

AND (dbo.itran.it_anal > ' ')  
AND  convert(int,dbo.ihead.ih_quodate) = convert(int,getdate())
0
Question has a verified solution.

Are you are experiencing a similar issue? Get a personalized answer when you ask a related question.

Have a better answer? Share it in a comment.

All Courses

From novice to tech pro — start learning today.