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 2005 Forums
 Transact-SQL (2005)
 select a specific month from a date

Author  Topic 

Ali T
Starting Member

22 Posts

Posted - 2008-08-05 : 04:39:06
Dear all
i have a table by the name of case1 with a date column by the name of date.the date is from 1/1/2008 to 1/3/2008 (d/m/y). i want to write a query that gives me the rows for the first month of 2008.what should i do?

Ali T

webfred
Master Smack Fu Yak Hacker

8781 Posts

Posted - 2008-08-05 : 04:48:13
select * from table where month(date)=1 -- maybe: and year(date)=2008

Webfred
Go to Top of Page

harlingtonthewizard
Constraint Violating Yak Guru

352 Posts

Posted - 2008-08-05 : 05:04:35
This may give you some ideas.
http://www.sqlteam.com/forums/topic.asp?TOPIC_ID=107666
Go to Top of Page

Ali T
Starting Member

22 Posts

Posted - 2008-08-05 : 05:22:53
quote:
Originally posted by webfred

select * from table where month(date)=1 -- maybe: and year(date)=2008

Webfred



thank you so much my friend. it worked.
Go to Top of Page
   

- Advertisement -