Link to home
Start Free TrialLog in
Avatar of techques
techques

asked on

How to pass string to datetime in a MSSQL query?

Hi

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?


SELECT [id]
      ,[transactiontypeid]
      ,[rate]
      ,[amount]
      ,[handlingfee]
      ,[countervalue]
      ,[transactiondatetime]
  FROM [FungKee].[dbo].[transactions]

Open in new window

ASKER CERTIFIED SOLUTION
Avatar of Pratima
Pratima
Flag of India image

Link to home
membership
This solution is only available to members.
To access this solution, you must be a member of Experts Exchange.
Start Free Trial
why B ?