Please start any new threads on our new site at https://forums.sqlteam.com. We've got lots of great SQL Server experts to answer whatever question you can come up with.

 All Forums
 SQL Server 2008 Forums
 Transact-SQL (2008)
 date format in string

Author  Topic 

desikankannan
Posting Yak Master

152 Posts

Posted - 2012-01-19 : 07:27:38
Hi,

i have date field iam stroring in datetime format "2011-12-26 17:18:01.093", what i want is that i if select the month of april then i should get the information relating to april month, pls guide how to retrive .


Desikankannan

sunitabeck
Master Smack Fu Yak Hacker

5155 Posts

Posted - 2012-01-19 : 07:33:28
Based on only what you described this should work:
SELECT 
col1,
col2,
col3
FROM
yourTable
WHERE
MONTH(datefield) = 4;
However, that would bring back data for every April regardless of the year. If you can post more details, I am sure some of the people on the forum can give better guidelines on what to do an what not to do. http://weblogs.sqlteam.com/brettk/archive/2005/05/25/5276.aspx
Go to Top of Page
   

- Advertisement -