How to pass string to datetime in a MSSQL query?

Posted on 2009-04-17
Last Modified: 2012-06-21

The transactiondatetime (datetime) in the following query is 2009-04-16 16:52:23.000

Now, I need to search only data in April

and the query

select * from transactions where transactiondatetime like '04' //04=April, string

It cannot search the result.

How should I write the query?








  FROM [FungKee].[dbo].[transactions]

Open in new window

Question by:techques
    LVL 39

    Accepted Solution


    select * from transactions where Month(transactiondatetime) = 4
    LVL 39

    Expert Comment

    by:Pratima Pharande
    why B ?

    Featured Post

    What Is Threat Intelligence?

    Threat intelligence is often discussed, but rarely understood. Starting with a precise definition, along with clear business goals, is essential.

    Join & Write a Comment

    This article will describe one method to parse a delimited string into a table of data.   Why would I do that you ask?  Let's say that you need to pass multiple parameters into a stored procedure to search for.  For our sake, we'll say that we wa…
    Recently, when I was asked to create a new SQL 2005 cluster, Microsoft released a new service pack for MS SQL 2005 what is Service Pack 3. When I finished the installation of MS SQL 2005 I found myself troubled why the installation of SP3 failed …
    how to add IIS SMTP to handle application/Scanner relays into office 365.
    This video gives you a great overview about bandwidth monitoring with SNMP and WMI with our network monitoring solution PRTG Network Monitor ( If you're looking for how to monitor bandwidth using netflow or packet s…

    754 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

    20 Experts available now in Live!

    Get 1:1 Help Now