Click here to Skip to main content
13,139,515 members (53,028 online)
Rate this:
Please Sign up or sign in to vote.
See more:

I have a column "WeekBeginningDate" where each and every day date(format-yyyy/mm/dd) is stored.I have to fetch the data based on first and last day of the particular month.

For ex:-If current month is January,I have to get records that are in this month from 01-01-2013 to 31-01-2013 and for february,I have to get records from 01-02-2013 to 29-02-2013 and so on for mar,april......upto dec....

Can you people please help me out.

Posted 7-Jan-13 21:22pm

1 solution

Rate this: bad
Please Sign up or sign in to vote.

Solution 1

datepart(month,getdate()) -- integer (1,2,3...)
,datepart(year,getdate()) -- integer
,datename(month,getdate()) -- January, February, etc

So you can select the month and the year as a string, the group based on that.
manasayarlagadda 8-Jan-13 3:34am
With this I can get only data related to only current month but I want data for all months........
Christian Graus 8-Jan-13 3:35am
Read my answer again. You can select the month and year as a single string, in your select statement, and then you can use 'group by' to group your data by month and year.
manasayarlagadda 8-Jan-13 3:56am
Sorry,I have tried it but its showing me the current month and current year data only.
Christian Graus 8-Jan-13 3:57am
Then you must be doing a where statement instead of a group by. Why not edit your post to show your code ? I can't fix what I can't see.

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)

  Print Answers RSS
Top Experts
Last 24hrsThis month

Advertise | Privacy |
Web04 | 2.8.170915.1 | Last Updated 8 Jan 2013
Copyright © CodeProject, 1999-2017
All Rights Reserved. Terms of Service
Layout: fixed | fluid

CodeProject, 503-250 Ferrand Drive Toronto Ontario, M3C 3G8 Canada +1 416-849-8900 x 100