Sql Date Query

Posted on 2011-04-20
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,
ORDER BY dbo.itran.it_anal


Question by:pepps11976
    LVL 33

    Accepted Solution

    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()))

    LVL 33

    Expert Comment

    or shorter:

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

    Featured Post

    Top 6 Sources for Identifying Threat Actor TTPs

    Understanding your enemy is essential. These six sources will help you identify the most popular threat actor tactics, techniques, and procedures (TTPs).

    Join & Write a Comment

    Suggested Solutions

    After restoring a Microsoft SQL Server database (.bak) from backup or attaching .mdf file, you may run into "Error '15023' User or role already exists in the current database" when you use the "User Mapping" SQL Management Studio functionality to al…
    Hi all, It is important and often overlooked to understand “Database properties”. Often we see questions about "log files" or "where is the database" and one of the easiest ways to get general information about your database is to use “Database p…
    Hi everyone! This is Experts Exchange customer support.  This quick video will show you how to change your primary email address.  If you have any questions, then please Write a Comment below!
    Polish reports in Access so they look terrific. Take yourself to another level. Equations, Back Color, Alternate Back Color. Write easy VBA Code. Tighten space to use less pages. Launch report from a menu, considering criteria only when it is filled…

    746 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

    Need Help in Real-Time?

    Connect with top rated Experts

    13 Experts available now in Live!

    Get 1:1 Help Now