request records from a specific month

Posted on 2011-10-14
Last Modified: 2012-06-27
EntryTime is a column with datetime as its format type.  

I want to request the number of records from the database where all the records are from July.

I know this code is wrong below
esql = "select count(*) from tblRegistration where EntryTime = 'July'

Open in new window

Question by:al4629740
    LVL 4

    Expert Comment

    Something like this?

    SELECT * FROM DateSample
    WHERE MONTH(DateVal) = 7

    Check out:

    Author Comment

    Can I do this instead

    SELECT * FROM tblRegistration WHERE MONTH(EntryTime) = 'July'

    I don't want to use numericals for the month
    LVL 23

    Accepted Solution


    SELECT * FROM tblRegistration WHERE datename(month, EntryTime) = 'July'

    LVL 23

    Expert Comment

    by:Rajkumar Gs
    Glad I could help you

    Featured Post

    What Security Threats Are You Missing?

    Enhance your security with threat intelligence from the web. Get trending threat insights on hackers, exploits, and suspicious IP addresses delivered to your inbox with our free Cyber Daily.

    Join & Write a Comment

    Suggested Solutions

    Introduction SQL Server Integration Services can read XML files, that’s known by every BI developer.  (If you didn’t, don’t worry, I’m aiming this article at newcomers as well.) But how far can you go?  When does the XML Source component become …
    Introduction In my previous article ( I showed you how the XML Source component can be used to load XML files into a SQL Server database, us…
    This videos aims to give the viewer a basic demonstration of how a user can query current session information by using the SYS_CONTEXT function
    Via a live example, show how to setup several different housekeeping processes for a SQL Server.

    732 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

    19 Experts available now in Live!

    Get 1:1 Help Now